Proposal: form_for_model exclude_fields

0 views
Skip to first unread message

Joseph Kocherhans

unread,
Oct 13, 2007, 3:27:48 AM10/13/07
to django-d...@googlegroups.com
I'd like to add an 'exclude_fields' keyword argument to
form_for_model, etc. exclude_fields would be a list of field names
that should be excluded from the form. If both 'fields' and
'exclude_fields' were passed in, exclude_fields would win for any
field that existed in both lists. Any objections or issues that need
further clarification?

I know the argument list for form_for_model is getting long, but
excluding fields is just so damn useful ;)

Joseph

Michael Elsdoerfer

unread,
Oct 13, 2007, 9:17:26 PM10/13/07
to django-d...@googlegroups.com
> I'd like to add an 'exclude_fields' keyword argument to
> form_for_model, etc. exclude_fields would be a list of field names
> that should be excluded from the form.

Maybe you are already aware of this, but I believe you can exclude fields if
you return None in the formfield callback. It's not as concise, but you can
always create your own wrapper.

Michael

Russell Keith-Magee

unread,
Oct 14, 2007, 8:47:27 AM10/14/07
to django-d...@googlegroups.com

+1 from me. Personally, I'm in favour of making form_for_model as
flexible as possible. 'exclude_fields' seems like a good move in that
direction.

Yours,
Russ Magee %-)

Malcolm Tredinnick

unread,
Oct 14, 2007, 1:12:03 PM10/14/07
to django-d...@googlegroups.com

-0 from me. form_for_* are going down the same path as generic views
where they are growing so many options the parameter list is becoming
it's own little language and people are using it as a crutch for
everything possible. You can already do this (via formfield_callback),
so we're just adding a second way.

I suspect I've already lost the battle to keep these function as simple
helpers, though, which is why I'm not -1.

Malcolm


Gary Wilson

unread,
Oct 15, 2007, 11:43:30 PM10/15/07
to django-d...@googlegroups.com
Russell Keith-Magee wrote:
> On 10/13/07, Joseph Kocherhans <jkoch...@gmail.com> wrote:
>> I know the argument list for form_for_model is getting long, but
>> excluding fields is just so damn useful ;)
>
> +1 from me. Personally, I'm in favour of making form_for_model as
> flexible as possible.

I would put myself in this boat as well. +1

> 'exclude_fields' seems like a good move in that
> direction.

Excluding fields is probably the most common thing I do to customize forms.

Gary

Italo Maia

unread,
Nov 5, 2007, 10:07:48 AM11/5/07
to Django developers
Is this an yes, a no, a maybe? It would be a pretty useful option.

On Oct 16, 12:43 am, Gary Wilson <gary.wil...@gmail.com> wrote:
> Russell Keith-Magee wrote:

Reply all
Reply to author
Forward
0 new messages