Unsupported Media Type

12 views
Skip to first unread message

göktürk sığırtmaç

unread,
Sep 20, 2019, 11:08:06 AM9/20/19
to Django REST framework
While i'm overriding post method from generics.ListCreateAPIView i have error unsupported media type but i don't send media. 

Serializer file:


class Users(serializers.Serializer):
username = serializers.CharField(max_length=50)
first_name = serializers.CharField(max_length=30)
last_name = serializers.CharField(max_length=150)
email = serializers.EmailField()
is_staff = serializers.BooleanField()
is_active = serializers.BooleanField()

Post method: 


def post(self, request):
serializer = serializers.Users(data=request.data)

if serializer.valid:
print("serializer.valid")
return Response(serializer.data, status=status.HTTP_200_OK)
else:
print("ELSE -- serializer.valid")
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

Postman:

Ekran Resmi 2019-09-20 18.03.35.png

Ekran Resmi 2019-09-20 18.02.22.png



Carl Nobile

unread,
Sep 20, 2019, 11:20:09 AM9/20/19
to django-res...@googlegroups.com
You must set media type for all your endpoints or they will default to DRF mime types.


--
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 django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/02a78ea9-4349-4f2c-819f-981894bad11a%40googlegroups.com.


--
-------------------------------------------------------------------------------
Carl J. Nobile (Software Engineer)
carl....@gmail.com
-------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages