﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18062	Document Best Practice for Choices in Model Fields	Thomas Güttler	nobody	"Document best practice of Model Field Choices:


{{{
    class User(models.Model):
        GENDER_MALE = 0
        GENDER_FEMALE = 1
        GENDER_CHOICES = [(GENDER_MALE, 'Male'), (GENDER_FEMALE, 'Female')]
        gender = models.IntegerField(choices=GENDER_CHOICES)
    
        def greet(self):
            return {GENDER_MALE: 'Hi, boy', GENDER_FEMALE: 'Hi, girl.'}[self.gender]

}}}

related thread in django-devel:

https://groups.google.com/group/django-developers/browse_frm/thread/cf1e8b22d4906559/249e082b30ecdc14

"	Cleanup/optimization	closed	Documentation	1.4	Normal	fixed		ognajd@…	Accepted	1	0	0	1	0	0
