Can't add a field with an election

Can't add a field with an election
python
Ethan Jackson

I'm student. Please don't scold me.

models.py:

from django.db import models class Teacher(models.Model): MATH = 'MT' PHYS = 'PH' COMP = 'CS' SUBJECTS_TEACHER_CHOICES = { MATH: 'Math', PHYS: 'Phys', COMP: 'Comp', } subjects = models.CharField( max_length=2, choices=SUBJECTS_TEACHER_CHOICES, default=MATH, ) first_name = models.CharField(max_length=128)

error: ERRORS: TeachersApp.Teacher.subjects: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples.

I want to add a field with choices.

Answer

Oh, okay. My version of django doesn't support that format.

Related Articles