Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HiddenField shows up in the HTML form of the web browsable API page #2410

Closed
Labels
Milestone
@lgp171188

Description

@lgp171188

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.

hiddenfield shown in html form

I am totally new to Django REST Framework, so sorry if I haven't RTFM and raised this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp