I have a small application that I wrote in python. Did some research on some web frameworks and decided to use django. I’m reading through the manual and going step by step to learn as much, however I’m stuck on the example given on page 19. When I type the command an I get and error.
import datetime
from django.utils import timezone
# ...
class Poll(models.Model):
# ...
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
Error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'models' is not defined
I googled “Django NameError:” and didn’t find much.
Thanks.
You accidentally missed the whole
importformodels.