﻿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
31313	Error in Example in Model field reference > Field.choices > Enumeration types	Lee Hopkins	Andrey Doroschenko	"The example in the new Field.choices Enumeration types documentation has an error:

{{{
class Student(models.Model):

    class YearInSchool(models.TextChoices):
        FRESHMAN = 'FR', _('Freshman')
        SOPHOMORE = 'SO', _('Sophomore')
        JUNIOR = 'JR', _('Junior')
        SENIOR = 'SR', _('Senior')
        GRADUATE = 'GR', _('Graduate')

    year_in_school = models.CharField(
        max_length=2,
        choices=YearInSchool.choices,
        default=YearInSchool.FRESHMAN,
    )

    def is_upperclass(self):
        return self.year_in_school in {YearInSchool.JUNIOR, YearInSchool.SENIOR}
}}}

The method `is_upperclass()` attempts to access the `YearInSchool` class directly, but cannot. The method should be:

{{{
    def is_upperclass(self):
        return self.year_in_school in {self.YearInSchool.JUNIOR, self.YearInSchool.SENIOR}
}}}

or:

{{{
    def is_upperclass(self):
        return self.year_in_school in {Student.YearInSchool.JUNIOR, Student.YearInSchool.SENIOR}
}}}

https://docs.djangoproject.com/en/3.0/ref/models/fields/#enumeration-types"	Cleanup/optimization	closed	Documentation	3.0	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
