In [12]: Question.objects.get(pub_date__year=current_year)
Towards the end of part 2, I have encountered two errors that I cannot resolve.
~~~--
In [14]: Question.objects.get(pub_date=current_year)---------------------------------------------------------------------------
FieldError: Cannot resolve keyword 'question_text_startswith' into field. Choices are: choice, id, pub_date, question_text
FieldError: Cannot resolve keyword 'pub_date_year' into field. Choices are: choice, id, pub_date, question_text
TypeError Traceback (most recent call last)<ipython-input-14-e3e7c7a858b4> in <module>----> 1 Question.objects.get(pub_date=current_year)~~~
Here is my code that I added according to the instructions:~~~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)
~~~and here are the questions that invoked these errors:~~~In [9]: Question.objects.filter(question_text_startswith='What')
In [12]: Question.objects.get(pub_date_year=current_year)
~~~
I think these are accurate representations of the text instructions.
What is wrong? Thank you.
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 django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ecc88bed-86a2-4d3b-a809-9ee588bdefd1n%40googlegroups.com.
-- Best regards, Maxim Zemlyakov Email: maxim.z...@gmail.com GSM: +79032703210