I have a user profile class and am checking if a user exists and if not want to create that user.
Am using the filter class for userprofile so that the client can call : http://localhost:8000/users/[email protected] and if the result is empty will create a user with the email address. Is there a way to intercept the query result and raise an exception when its empty and handle that to create the user. If there is a better way would like to be corrected as well. class UserQueryFilter(django_filters.rest_framework.FilterSet): email = django_filters.CharFilter(name="user__email") username = django_filters.CharFilter(name="user__username") class Meta: model = UserProfile fields = ['email', 'username'] class UserViewSet(viewsets.ReadOnlyModelViewSet): queryset = UserProfile.objects.all() serializer_class = UserSerializer filter_class = UserQueryFilter Any help is appreciated. Thanks Anand -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
