#4620: Custom labels for choices in ModelChoiceField
----------------------------------------------+-----------------------------
Reporter: Bill Fenner <[EMAIL PROTECTED]> | Owner: nobody
Status: reopened | Component:
django.newforms
Version: 0.96 | Resolution:
Keywords: | Stage: Design
decision needed
Has_patch: 1 | Needs_docs: 1
Needs_tests: 1 | Needs_better_patch: 0
----------------------------------------------+-----------------------------
Changes (by SmileyChris):
* status: closed => reopened
* resolution: wontfix =>
Comment:
It's a lot of hoops to jump through to do that however:
1. Subclass `QuerySetIterator`
2. On your iterator subclass, override (and duplicate most of) the
`__iter__` method to just yield something other than `smart_unicode(obj)`
3. Subclass `ModelChoiceField` or `ModelMultipleChoiceField`
4. On your field subclass, create (mostly duplicate) `_get_choices` and
`_set_choices` methods and set `choices = property(_get_choices,
_set_choices)` so you can use your subclassed iterator
I've had this request again recently on IRC - are you sure it's wontfix?
(even if it is in a different way to the current patch)
--
Ticket URL: <http://code.djangoproject.com/ticket/4620#comment:5>
Django Code <http://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
-~----------~----~----~----~------~----~------~--~---