I’m new to Django with its tutorial -part 1 : Write your first app. when I want to see my Poll objects in python shell with this command Poll.objects.all(), I see [<Poll: Poll object>], however I’ve changed my models.py and added
class Poll(models.Model):
def __unicode__(self):
return self.question
class Choice(models.Model):
def __unicode__(self):
return self.choice
but I should see this:
[<Poll: What's up?>]
What’s the problem?
finally I found my answer:
according to the tutorial, I added this code to my models.py :
def was_published_today(self):return self.pub_date.date() == datetime.date.today()
but when I remove these two lines, I can see “what’s up?” and not
[<Poll: Poll object>]!! I don’t know why this happen exactly? but it just worked!I’m new to django and python but i think this caused for not defining was_published_today under Poll class?! they probably just missed it…