1

Unable to set rating choice through Django admin console Error: Select a valid choice. 2 is not one of the available choices.

models.py

    from model_utils import Choices

class Course_Feedback(models.Model):
    course = models.ForeignKey(Course, on_delete=models.PROTECT, related_name='course_feedback')
    RATING = Choices(1, 2, 3, 4, 5)
    rating = models.CharField(choices=RATING, null=True, max_length=2)

cant we use integers in choices directly ?

user11879807
  • 251
  • 1
  • 3
  • 11

1 Answers1

0

My mistake: rating should be an integer field

rating = models.IntegerField(choices=RATING, null=True, max_length=2)

user11879807
  • 251
  • 1
  • 3
  • 11