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.