Answers for "django rest authentication api tutorial"

8

pip install django rest framework

pip install djangorestframework
pip install markdown       # Markdown support for the browsable API.
pip install django-filter  # Filtering support
Posted by: Guest on November-20-2020
0

User serializer in django rest framework

class EventSerializer(serializers.ModelSerializer):

    class Meta:
        model = models.Event
        exclude = ['user']


class EventView(APIView):

    def post(self, request):
        es = EventSerializer(data=request.data)
        if es.is_valid():
            es.save(user=self.request.user)
            return Response(status=status.HTTP_201_CREATED)
        return Response(data=es.errors, status=status.HTTP_400_BAD_REQUEST)
Posted by: Guest on August-20-2020

Code answers related to "django rest authentication api tutorial"

Python Answers by Framework

Browse Popular Code Answers by Language