How to create a multi valued field in the model?

287 views
Skip to first unread message

Daniel Grace

unread,
Mar 23, 2015, 7:28:40 PM3/23/15
to django...@googlegroups.com
How to create a field with multiple values?  For example an integer field that takes on particular values:

state = models.IntegerField()

... where state=0 represents 'pending', state=1 represents 'accepted' and state=2 represents 'rejected'.
Is it possible to put these values / constants into the model?

Vijay Khemlani

unread,
Mar 23, 2015, 7:35:05 PM3/23/15
to django...@googlegroups.com

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0ffb0a31-d900-4b62-826b-b779bab472a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Filipe Ximenes

unread,
Mar 23, 2015, 8:57:23 PM3/23/15
to django...@googlegroups.com
I'd also recommend using the "Choices" functionality of the Django Model Utils project. It will give you good tools to keep the code readable, simplify access and presentation of data:



For more options, visit https://groups.google.com/d/optout.



--
  
Filipe Ximenes
+55 (81) 8245-9204
Vinta Software Studio
http://www.vinta.com.br
Reply all
Reply to author
Forward
0 new messages