Hi,
I'm new to django and programing. I was following the tutorial and get
to the following:
Wait a minute. <Poll: Poll object> is, utterly, an unhelpful
representation of this object. Let's fix that by editing the polls
model (in the polls/models.py file) and adding a __str__() method to
both Poll and Choice:
class Poll(models.Model):
# ...
def __str__(self):
return self.question
class Choice(models.Model):
# ...
def __str__(self):
return self.choice
I'm not sure how to use it in models.py, do I remove the original
method or dose it need to be combined?
Current models.py
from django.db import models
class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(maxlength=200)
votes = models.IntegerField()
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---