'choices' must be an iterable containing (actual value, human readable name)

Viewed 121

I am trying to make migrations but I can't.

the CODE:

from .setting import WORK_TYPE,USER_ACCOUNT

class Rating (models.Model):
    RATING_CHOICES = (
    ('poor','Poor'),
    ('average', 'Average'),
    ('good', 'Good'),
    ('verygood', 'Very Good'),
    ('excellent', 'Excellent')
),
    rating = models.CharField(max_length=30,choices=RATING_CHOICES, default='poor')
    create_at=models.DateTimeField(auto_now_add=True)
    update_at=models.DateTimeField(auto_now=True)

And this gives the error: 'choices' must be an iterable containing (actual value, human readable name)

1 Answers

You forgot the bracket for your choices, your code should be:

RATING_CHOICES = [(
('poor','Poor'),
('average', 'Average'),
('good', 'Good'),
('verygood', 'Very Good'),
('excellent', 'Excellent')
),]

Model Choice documentation

Related