thank you, but that does not seem to be the problem. Maixm below solved the problem if you are interested.
On Wednesday, August 26, 2020 at 12:12:34 PM UTC-7 Ogunsanya Opeyemi wrote: > You have not defined current_year > > On Wednesday, August 26, 2020, [email protected] <[email protected]> > wrote: > >> Looking at my post it seems that there is not much to go on in terms of >> understanding my problem. So, let me try to provide more detail. >> >> I am in part 2 of the tutorial working with "models" (sqlite) and have >> written this code into "polls/models.py: >> >> ~~~ >> from django.db import models >> from django.utils import timezone >> import datetime >> >> # Create your models here. >> >> class Question(models.Model): >> question_text = models.CharField(max_length=200) >> pub_date = models.DateTimeField('date_published') >> def __str__(self): >> >> return self.question_text >> >> def was_published_recently(self): >> >> return self.pub_date >= timezone.now() >> >> datetime.timedelta(days=1) >> >> >> class Choice(models.Model): >> question = models.ForeignKey(Question, on_delete=models.CASCADE) >> choice_text = models.CharField(max_length=200) >> votes = models.IntegerField(default=0) >> def __str__(self): >> >> return self.choice_text >> >> ~~~ >> The indents are correct, just not shown in the markdown. >> >> This is the shell command that brought the error: >> >> Question.objects.get(pub_date_year=current_year) >> >> Something is wrong with defining "current_year" and making it work. Can >> anyone see the problem? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/f326a70c-50a4-4f0a-a2d5-69e205ea0933n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/f326a70c-50a4-4f0a-a2d5-69e205ea0933n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > OGUNSANYA OPEYEMI > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3e744c48-efe2-4bbe-9afe-14e8f6995563n%40googlegroups.com.

