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