[Django] #23921: Can't hide a hidden field in the django admin

66 views
Skip to first unread message

Django

unread,
Nov 26, 2014, 10:27:38 AM11/26/14
to django-...@googlegroups.com
#23921: Can't hide a hidden field in the django admin
-------------------------------+--------------------
Reporter: DoctorMalboro | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I have a form in django 1.6.5 like this:

{{{
#!python
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23921>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 26, 2014, 10:43:26 AM11/26/14
to django-...@googlegroups.com
#23921: Can't hide a hidden field in the django admin
-------------------------------+--------------------------------------
Reporter: DoctorMalboro | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.6
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

Have you tried
[https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form
ModelAdmin.form]?

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

--
Ticket URL: <https://code.djangoproject.com/ticket/23921#comment:1>

Reply all
Reply to author
Forward
0 new messages