Tuesday, September 6, 2011

Re: forms.ChoiceField/forms.ModelChoiceField Needs a Lot of Love

On 05-09-11 23:09, Terribyte wrote:
> I don't know if anyone has said this outright, but I think that
> ChoiceField and ModelChoiceField are just broken.
>
> It seems that every time I want to do something with them I'm having
> to write a custom init function get what I want done.
>
> As a community I think we should be able to improve the "genericness"
> of them in such a way that would allow smart filtering of model lists,
> default settings, and a few other features that as an object they are
> wonting for.
>
> I know that this remark is far too generic and requires a great deal
> more "fleshing out" but I wanted to throw that out there as I'm
> banging my head -- once again -- on the desk trying to get django
> forms to spit out a choice field that does what I want it to do and
> wished to share my frustration.

I hope it helped :-)

From time to time someone says that a feature that's been a long time
in Django is "just broken". Well, the common answer is that that's
nonsense, precisely because it is in Django for a long time and lots of
people are using it. So it cannot be broken. Perhaps sub-optimal, but
not broken.

Just telling you the standard reaction I've seen :-)

I *guess* that choice fields is a pretty hard problem to solve correctly
and probably impossible to solve generically. Perhaps a custom init
function *is* the right way?

Anyway, could you give an example where you have to write a custom init?
Mayhap there's an easy solution, mayhap it suggests improvements to the
generic choicefield?


Reinout

--
Reinout van Rees http://reinout.vanrees.org/
reinout@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment