"An iterable (e.g., a list or tuple) consisting itself of iterables of exactly two items"
I don't think that constructing choices as a "iterableof 1 item iterables" will work.
Think of each item in the choices iterables as a key-value pair, where the first item is the key (literally is the value that is saved on the DB field), and the value is the "display value".
Em 29 de jun de 2017 7:14 PM, "Rich Shepard" <rshepard@appl-ecosys.com> escreveu:
On Thu, 29 Jun 2017, Guilherme Leal wrote:
It wouldn't be the case to use the field choices?
https://docs.djangoproject.com/en/1.11/ref/models/fields/# django.db.models.Field.choices
Guilherme,
Now that I know Field.choices exists it will certainly do the job.
I read the example as translating a quoted string in two steps to a
two-character, uppercase abbreviation. Would the following one-step list of
choices be correct?
industry_choices (
('Agriculture'),
('Business, other'),
('Chemicals'),
('Energy'),
('Law'),
('Manufacturing'),
('Mining'),
('Municipalities'),
('Ports/Marine Services'),
('Transportation'),
)
industry=models.CharField(max_length=24, choices=industry_choices, default='Agriculture')
Thanks,
Rich
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+unsubscribe@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/CAOs3Lp7HBbPEUBCQnpagDfqp7qt%3DfsYWpnRSqE2LkqDrx%2Bs7Og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment