Thursday, June 30, 2011

Re: Problem with Tutorial 1 - Django Version = 1.3

Op donderdag 30 juni 2011 14:57:46 UTC+1 schreef Eiram het volgende:
Greetings!!

In the past few days I have been trying to learn about Django.  I
started doing the Tutorial 1. During the tutorial I'm getting a
strange error. I was hoping if someone can help me to understand what
I'm doing wrong and how can I fix it.

This is the code I had:

class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
def __unicode__(self):
        return self.question

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(max_length=200)
    votes = models.IntegerField()
def __unicode__(self):
        return self.choice

When I execute the command Poll(objetcs.all): I get as result the
following: class [<Poll: Poll object>, <Poll: Poll object>] when I;m
supposed to get as result [<Poll: What's up?>]

I don't know what is missing. If someone can help me I would
appreciate it. Thanks!!


Indentation! Both `def __unicode__` lines need to be at the same level as the lines above them.
--
DR. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-eTqM61-4OwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment