Opened 9 years ago

Closed 9 years ago

#23921 closed Bug (invalid)

Can't hide a hidden field in the django admin

Reported by: Leandro Poblet Owned by: nobody
Component: Forms Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a form in django 1.6.5 like this:

class ExampleForm(forms.ModelForm):

   id_image = forms.CharField(widget=forms.HiddenInput())
   image = forms.ImageField(widget=CustomImageUploader())

   # Tried this
    def __init__(self, *args, **kwargs):
        super(ExampleForm, self).__init__(*args, **kwargs)
        if self.instance and self.instance.pk:
            self.fields['id_image'].widget = forms.HiddenInput()

   class Meta:
      fields = ('id_image', 'image',)

And I couldn't find a way to hide the form in the django's admin. I can't exclude it because I have a custom form with a javascript function that fills the id_image field, so the only way I have to do this is by hiding the value, because it doesn't look nice for the end user.

Change History (1)

comment:1 by Tim Graham, 9 years ago

Resolution: invalid
Status: newclosed

Have you tried ModelAdmin.form?

Please see TicketClosingReasons/UseSupportChannels for ways to get help. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top