How to use Enums for Django Field.choices Posted by rodwyer on Monday February 17, 2014 @07:45PM from the blog.richard.do dept. http://blog.richard.do/index.php/2014/02/how-to-use-enums-for-django-field-choices/ ( 1 comment | on HN )
<code>
class Section(TransformerCommon): """ working model """ TEMPERATURE_COLD = 20
... end_ins_location = models.IntegerField( choices=END_INSULATION_LOC_CHOICES, verbose_name="End Insulation Location") ... try: if self.end_ins_location == Section.NONE: ... elif self.end_ins_location == Section.END: ... elif self.end_ins_location == Section.BOTH: ... else: ...</code>