#17301: Defining fieldsets in a form class
-------------------------------------+-------------------------------------
Reporter: msiedlarek | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: SVN
Severity: Normal | Resolution:
Keywords: form, forms, | Triage Stage: Accepted
fieldsets | Needs documentation: 1
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by lrekucki):
I found two odd things in your patch:
One was partially already in Django:
{{{
try:
parents = [b for b in bases if issubclass(b, ModelForm)]
except NameError:
# We are defining ModelForm itself.
parents = None
}}}
Your patch changes {{{ModelForm}}} to {{{BaseModelForm}}} which makes the
"{{{try: except:}}}" look silly, because it will never trigger. It's also
now duplicated in {{{BaseFormMetaclass}}}.
Second, is the doubled call to {{{BaseFormOptions.__init__}}}.
I fixed the second by adding {{{make_options}}} method on the metaclass,
which can be then overriden, and the first by using {{{isinstance(b,
cls)}}} instead of {{{issubclass}}}. This has a small caveat, that it will
consider any class using this metaclass as a parent of the form (not just
subclasses of BaseForm/BaseModelForm), but I'm pretty sure that anyone
doing this, really knows the implications.
--
Ticket URL: <https://code.djangoproject.com/ticket/17301#comment:6>
Django <https://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.