#31043: From with ModelChoiceField and disabled failed when the initial is model instance and not pk -----------------------------------------+------------------------ Reporter: Eran Keydar | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 2.2 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -----------------------------------------+------------------------ Got this issue in some more complex example, narrows down to this scenario:
{{{ class Form1(forms.Form): user = forms.ModelChoiceField( queryset=get_user_model().objects.all(), disabled=True, initial=get_user_model().objects.get(pk=1) ) label = forms.CharField() }}} Then {{{ In [12]: f = Form1(data={'label':'aaa'}) In [13]: f.is_valid() Out[13]: False In [14]: f.errors Out[14]: {'user': ['Select a valid choice. That choice is not one of the available choices.']} }}} If the initial changed to the pk itself, everything works fine -- Ticket URL: <https://code.djangoproject.com/ticket/31043> Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.770158837c539a47106e430cc7418f98%40djangoproject.com.