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?