0

Well, the problem is simple. If I post my data via the HTML form, a new record is created in the DB but all data passed is null, as shown in the picture.

post response via html form

However, if a use the "raw_data" interface, everything works just fine:

post response via raw data

Code is quite simple:

views.py:

class CollectionList(generics.ListCreateAPIView):
    queryset = Collection.objects.all()
    serializer_class = CollectionSerializer

serializer.py:

class CollectionSerializer(serializers.ModelSerializer):
  class Meta:
    model = Collection
    fields = ('id','title', 'nlikes')  

Any suggestion?

1 Answer 1

1

You simply need to upgrade django rest framework to 3.3.1. There was a bug in 3.3.0 that sets all form data to empty values when using the session login.

Edit: The issue was https://github.com/tomchristie/django-rest-framework/issues/3574

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.