Older related ticket: https://code.djangoproject.com/ticket/4620

My rough draft of proposed 
changes: 
https://gist.github.com/mekhami/24af779f4f491d3c66e6fd607c2121aa/revisions

The problem of setting the label for ModelChoiceField is one that comes up 
on IRC every once in a while. It's a common enough problem that I think the 
documentation-recommended solution of subclassing ModelChoiceField and 
setting label_from_instance 
( https://docs.djangoproject.com/en/1.10/ref/forms/fields/#modelchoicefield 
) is overkill, and probably a maintenance problem.

ModelChoiceField already implements an optional callable in the 
`get_limit_choices_to` function. This change would implement a similar API 
to allow a callable to be passed in to the constructor rather than having 
to do the subclassing dance.

It'd still be backwards compatible, but the documentation should be changed 
to reflect the "easier" solution of passing in the callable.

The old ticket was labelled wontfix, but I think we should take a look 
again. I'd love for this to be my first contribution to Django! Thanks for 
any feedback. And if I forgot something or broke a rule for the ML, I 
apologize in advance @.@

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/23d3d7ae-eb5b-409b-a9ec-a91ac0f22390%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to