I think you should just call all object instead of using values ( ) and __str__ will give you the names of customer I am not sure but this should work
On Wed 12 Dec, 2018, 3:46 AM madjardi, <malinich.mali...@gmail.com> wrote: > aybe it help You > > https://stackoverflow.com/questions/42157384/django-how-to-change-value-of-forms-modelchoicefield > > среда, 12 декабря 2018 г., 0:34:47 UTC+3 пользователь progm...@gmail.com > написал: >> >> Hi, >> I'm struggling to set up a data-bound(queryset) ModelChoiceField. Here is >> the forms.py code to populate the control: >> >> class frmCustomerList(forms.Form): >> customerlist = forms.ModelChoiceField(queryset=dbCustomer.objects.values( >> 'name').order_by('name').distinct()) >> >> This is working but is formatted incorrectly. It displays as: >> >> [image: choices.png] >> >> >> >> I actually need only the 'Customer 1' to show. In fact, I would like the >> database's primary key('id') as a hidden key or value in the control and >> use the actual data('Customer 1') only for the visible display. >> >> I can't work it out. if I add 'id' to the queryset fields I get this: >> >> >> [image: choices2.png] >> >> >> >> Can I get some examples, maybe some explanations also. >> >> >> Thanks >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/0a1b00b9-43d7-4785-aab4-34d141b0c22a%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/0a1b00b9-43d7-4785-aab4-34d141b0c22a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALpJ3uL2TzAFS7vxU-Mx4jtVg3VF8bHNo%2BKD%2B649_e_4xnXsEg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.