POST in DRF works when not logged in. Doesn't otherwise

14 views
Skip to first unread message

Nkansah Rexford

unread,
Nov 9, 2015, 11:41:10 AM11/9/15
to Django REST framework
Perhaps changes happened in 3.3.0 that I'm yet to know of. This is what happens.
When I submit a form using the DRF web browser when I'm logged in, I get "This field is required" error on all the fields
When I'm logged out, the form submits successfully.

What am I missing here? Thanks

My model:
class Student(models.Model):
    name = models.CharField(max_length=200)
    address = models.TextField()
    phone = models.CharField(max_length=15)
    remarks = models.TextField()


My serializer:
class StudentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Student
        fields = ('id', 'name', 'address', 'phone', 'remarks')

My view:
class StudentList(generics.ListCreateAPIView):
    queryset = Student.objects.all()
    serializer_class = StudentSerializer


My url:
    url(r'^api/student/$', views.StudentList.as_view(), name='student_list'),



Xavier Ordoquy

unread,
Nov 9, 2015, 12:20:45 PM11/9/15
to django-res...@googlegroups.com
Hi,

This was a bug in 3.3.0. You should upgrade to 3.3.1 to fix it.

Regards,
Xavier,
Linovia.

--
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.
For more options, visit https://groups.google.com/d/optout.

Nkansah Rexford

unread,
Nov 9, 2015, 5:11:42 PM11/9/15
to Django REST framework
oooh good, thanks

I reverted back to 3.0 and it has been working. Will move up to the 3.3.1
Thanks
Reply all
Reply to author
Forward
0 new messages