Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Closed
Labels
Milestone
Description
I have a model with a foreign key reference to the User model called 'user'. In my serializer class, which is a sub-class of ModelSerializer, I have overridden the default field created by ModelSerializer and set it to:
user=serializers.HiddenField(default=serializers.CurrentUserDefault())
When displaying the fields in the API response, this field is indeed hidden, but in the web browsable API page, the HTML form shows a textbox for the user field which is supposed to be hidden.
Here is my serializer definition:
classCategorySerializer(serializers.ModelSerializer):user=serializers.HiddenField(default=serializers.CurrentUserDefault())classMeta:model=Categoryfields= ('name','description','created','modified','user')
Please see the screenshot illustrating the HTML form with an input for the hidden field.
I am totally new to Django REST Framework, so sorry if I haven't RTFM and raised this issue.
