Thank you Mathew now it is working fine On Tue 1 May, 2018, 2:39 AM Matthew Pava, <[email protected]> wrote:
> You need a space between def and __str__ > > > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *Avitab Ayan Sarmah > *Sent:* Monday, April 30, 2018 4:07 PM > *To:* Django users > *Subject:* I am following the official Django documentation and trying to > make the polls app. But when I run the command python manage.py shell I get > the console error. > > > > The code of my polls/models.py is: > > import datetime > > > > from django.db import models > > from django.utils import timezone > > > > > > class Question(models.Model): > > #... > > def was_published_recently(self): > > return self.pub_date >= timezone.now() - datetime.timedelta(days=1) > > def__str__(self): > > return self.question_text > > question_text = models.CharField(max_length=200) > > pub_date = models.DateTimeField('date published') > > > > class Choice(models.Model): > > #... > > def__str__(self): > > return self.choice_text > > question = models.ForeignKey(Question, on_delete=models.CASCADE) > > choice_text = models.CharField(max_length=200) > > votes = models.IntegerField(default=0) > > > > Please find the error in my code and help me run my code.The error is > attached above > > -- > 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 post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/84560734-c5cd-4e32-9da4-7aba3202c402%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/84560734-c5cd-4e32-9da4-7aba3202c402%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/xTxwDaYLcYk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/93d21fa128fa46c5a57ec72b7cfd997b%40ISS1.ISS.LOCAL > <https://groups.google.com/d/msgid/django-users/93d21fa128fa46c5a57ec72b7cfd997b%40ISS1.ISS.LOCAL?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEx5wm7snNfKwsLCLh8H96taGkEizFQmtnChomb0CzyPZQ070g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

