Sunday, July 28, 2019

Re: Djago Rest framework Error

I'm assuming you have used ModelViewSet.

In that you can always call this method:

def get_serializer_class(self):
if self.request.user and self.request.user.is_authenticated:
return ProfileSerializer
else:
return UserSerializer

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b11e0a39-ba45-46b6-8488-f6ac0fcce497%40googlegroups.com.

No comments:

Post a Comment