Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active August 25, 2020 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/a00f0095bd859b9c29ff38e3f27e7258 to your computer and use it in GitHub Desktop.
Save velotiotech/a00f0095bd859b9c29ff38e3f27e7258 to your computer and use it in GitHub Desktop.
# override the get_serializer_context method in the generic viewset
class UserCreateListAPIView(generice.ListCreateAPIView):
def get_serializer_context(self):
context = super().get_serializer_context()
# Update context data to add new data
context.update({"valid_domains": ValidDomain.objects.all()})
return context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment