#8620: ModelForm.Meta.exclude only excludes model fields, not form fields
---------------------------+------------------------------------------------
 Reporter:  levity         |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  SVN       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 If I have a ModelForm that inherits from another form, and I define
 exclude and/or fields, these only affect fields on the model. I cannot use
 them to exclude any non-model fields that I may have added to the ancestor
 form. E.g.:


 {{{
 class AForm(ModelForm):
   extra_non_model_field = forms.CharField()

 class BForm(AForm):
   class Meta:
     model = Foo
     exclude = ('extra_non_model_field',) # this doesn't work, due to the
 way ModelFormMetaclass.__new__ is written
 }}}


 Sure that's a pathological example, but there are more sensible situations
 in which this is an issue. Seems to me it's more intuitive to expect the
 exclude/fields options to affect all fields, not just model fields.

 A fix would be to add this at django/forms/models.py line 180:

 {{{
         [declared_fields.pop(f) for f in declared_fields.keys() if f not
 in opts.fields or f in opts.exclude]
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8620>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to