Create a hidden field in the admin site

前端 未结 5 785
孤街浪徒
孤街浪徒 2021-01-11 18:57

How can I create a fully hidden field (input and label) in the admin site? I know about the exclude property, but it fully excludes the field from the template,

5条回答
  •  情书的邮戳
    2021-01-11 19:24

    You're giving ModelForm in your example, not ModelAdmin you should be using for admin site.

    Anyway, method of excluding some field is the same: specify it in exclude property:

    class OutForm(ModelForm):
      class Meta:
        exclude = ["reply_to"]
    

    or

    class OutAdmin(ModelAdmin):
      exclude = ["reply_to"]
    

    See Django documentation for details: http://docs.djangoproject.com/en/1.2/ref/contrib/admin/

提交回复
热议问题