proposal Meta.exclude in Form

18 views
Skip to first unread message

Constantine

unread,
Apr 19, 2011, 11:57:51 PM4/19/11
to Django developers
FormModel have exclude attribute in Meta, but simple Form doesnt:
example usage:

i need base form for editing with many fields, and derived form for
object creation with subset of fields and so i want to exclude
unnecessary fields

Constantine

unread,
Apr 20, 2011, 12:37:43 AM4/20/11
to Django developers
generally it's lack of Meta subclass in simple form, in which we can
configure fields order, exclusion of some fields etc. Now i should
override __init__ method, its not so declarative way as in modelform

Xavier Ordoquy

unread,
Apr 20, 2011, 1:26:42 AM4/20/11
to django-d...@googlegroups.com

Actually, I don't understand.
If you need object creation, ModelForm is the way to go.
You could also take it the other way. Base form should be the one with the smallest field set.

Regards,
Xavier.

Constantine

unread,
Apr 20, 2011, 3:22:31 AM4/20/11
to Django developers
On Apr 20, 12:26 pm, Xavier Ordoquy <xordo...@linovia.com> wrote:
> Le 20 avr. 2011 à 05:57, Constantine a écrit :
...
> Actually, I don't understand.
> If you need object creation, ModelForm is the way to go.
unfortunately ModelForm is not suitable
> You could also take it the other way. Base form should be the one with the smallest field set.
You are right, base form has the smallest set.
But inheritors' field sets highly intersects and i'cant distinguish
minimum set for base class
>
> Regards,
> Xavier.

Anyway, what's the reason for not implementing Meta in Forms

Regards,
Constantine

Xavier Ordoquy

unread,
Apr 20, 2011, 4:00:23 AM4/20/11
to django-d...@googlegroups.com

Le 20 avr. 2011 à 09:22, Constantine a écrit :

> On Apr 20, 12:26 pm, Xavier Ordoquy <xordo...@linovia.com> wrote:
>> Le 20 avr. 2011 à 05:57, Constantine a écrit :
> ...
>> Actually, I don't understand.
>> If you need object creation, ModelForm is the way to go.
> unfortunately ModelForm is not suitable
>> You could also take it the other way. Base form should be the one with the smallest field set.
> You are right, base form has the smallest set.
> But inheritors' field sets highly intersects and i'cant distinguish
> minimum set for base class

I doubt Django devs will include Meta.exclude in Form without a fully described use case.
The general idea is don't include feature unless there's no other way.
In your case, I can't see why you can't use a base form and extend it.

Xavier.

PS:
I'm not a Django core dev.
I just noticed this is on django dev mailing list so don't take my words as official core team answer.

Constantine

unread,
Apr 20, 2011, 4:09:40 AM4/20/11
to Django developers
i've workaround this overloading init, so the other way exist.
But i surprised when not found meta class in simple form (model and
modelform have)
Regards,
Constantine
Reply all
Reply to author
Forward
0 new messages