Hi everyone,
I need to add a checkbox field to an ModelForm, which is easy enough
by overriding __init__ on the ModelForm, but I'm also using a custom
fieldset on the ModelAdmin.
So, I need to be able to add the field to the fieldset from the form's
__init__
Possible? I'm not sure how I can get to the ModelAdmin through the
Model...
#my forms.py
class BidAdminForm(forms.ModelForm):
class Meta:
model = Bid
def __init__(self, *args, **kwargs):
super(BidAdminForm, self).__init__(*args, **kwargs)
#Only show the inherit checkbox for a new Bid
if not self.instance.id:
self.fields['inherit_entity_location_groups'] =
forms.BooleanField()
...at this point, self.instance will get me to the Bid model, but when
I try to access the model_admin on the instance, I get an
AttributeException.
I'd really appreciate some help!
TIA,
Brandon
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.