Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML form in generics.listCreateAPI is not taking values #3574

Closed
hawksterdhruv opened this issue Oct 30, 2015 · 3 comments
Closed

HTML form in generics.listCreateAPI is not taking values #3574

hawksterdhruv opened this issue Oct 30, 2015 · 3 comments
Labels
Milestone

Comments

@hawksterdhruv
Copy link

When we try to submit json through the HTML form where the view is created with ListCreateAPI, it is not saving the values. If we save it using the application/json, it saves the values.
This was working fine in version 3.2.5 but it is not working in version 3.3.0

@xordoquy
Copy link
Collaborator

Is it possible to come with the simplest test case to demonstrate what doesn't work ?

@knoppo
Copy link

knoppo commented Nov 2, 2015

same here,
I'm able to reproduce this in a fresh install with a required charfield:

# models.py
class Forum(models.Model):
    title = models.CharField(max_length=50)

# serializers.py
class ForumSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Forum
        fields = ('url', 'title')

# settings.py
REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',),
    'PAGE_SIZE': 10,
}

I can post new data by using "Raw Data" with a media type "application/json", but "multipart/form-data" always gives a 400 Bad Request with a validation error {"title": "field is required."}

After some debugging I found out that when calling DjangoMultiPartParser a second time (from MultiPartParser) it seems like the stream is already consumed. (parsers.py:114)

broke: drf 3.3.0, django 1.8.5
works: drf 3.2.5, django 1.8.5

@xordoquy
Copy link
Collaborator

xordoquy commented Nov 2, 2015

Ok, this seems linked with the permission class.
Could reproduced the issue with the permission class set but it works when the permission isn't set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants