> Also, when the number of choices is big, none of the provided widgets
> are very usable, so I have for instance created a TreeSelect widget
> which groups choices into categories (columns in the table) and
> displays them in a tree whose branches are collapsible (see an example
> at [1]).  But in order to do that, the widget needs to know its
> field's queryset, not just its choices.
>
> But as far as I can see, there is no builtin way, when you change the
> queryset property of a [Multiple]ModelChoiceField, for this change to
> propagate automatically to its widget.  

I totally agree.  A common use case I've encountered when using the
admin (specifically, I'm using newforms-admin) is the ability to
override the Model[Multiple]Choice field to only display the related
objects associated with a given model in the admin.  Otherwise, the
browser buckles under the pressure of having to populate a <select>
element with thousands of possibilities.  I believe such a
customization hook would benefit newforms-admin, and as customization
hooks are currently being discussed in a separate thread [1] perhaps
it should be mentioned again there.

Now before someone comes saying "use raw_id_fields", they are
insufficient because they are, well, too "raw" -- forcing a client to
input integer ids is not my idea of user friendly. I had to come up
with my own form fields, widgets, and a `ModelAdmin` subclass to
accomplish the customization of the queryset displayed to the user
[2].  Much of the code would be unnecessary if it was possible to
easily override the queryset.

[1] Simon Willison, "newforms-admin customisation hook suggestions",
http://groups.google.com/group/django-developers/browse_thread/thread/53eaa25074ff4369
[2] http://geodjango.org/hg/limited_related/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to