I am having an issue with Django and Python
I am facing the error .from_hour: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples.
Can someone help me understand what the error is? I know if I comment from_hour
and to_hour
it runs
Here is my code
WEEKDAYS = [
(1, _("Monday")),
(2, _("Tuesday")),
(3, _("Wednesday")),
(4, _("Thursday")),
(5, _("Friday")),
(6, _("Saturday")),
(7, _("Sunday")),
]
weekday_from = models.IntegerField(choices=WEEKDAYS, unique=True)
weekday_to = models.IntegerField(choices=WEEKDAYS)
from_hour = models.IntegerField(choices=range(1,25))
to_hour = models.IntegerField(choices=range(1,25))
def get_weekday_from_display(self):
return WEEKDAYS[self.weekday_from]
def get_weekday_to_display(self):
return WEEKDAYS[self.weekday_to]
you must use WEEKDAYS.choices in choices attr, change this line:
weekday_from = models.IntegerField(choices=WEEKDAYS, unique=True)
to
weekday_from = models.IntegerField(choices=WEEKDAYS.choices, unique=True)
you must set values in ''
STATUS_CHOICES = (
('d', 'Draft'),
('p', 'Published'),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With