It IS indented correctly, it looks like it wasn't due to copy/paste
but it is in fact inline with def __str__(self): BTW running .96.1

On Jul 1, 12:26 pm, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-07-01 at 12:18 -0700, [EMAIL PROTECTED] wrote:
> > Hello,
>
> > I'm just going through this tutorial and the custom method
> > was_published_today() is not recognized as an attribute of Poll,
> > though it's defined in the model as follows:
>
> > from django.db import models
> > import datetime
>
> > class Poll(models.Model):
> >     question = models.CharField(maxlength=200)
> >     pub_date = models.DateTimeField('date published')
> >     def __str__(self):
> >         return self.question
> >    def was_published_today(self):
> >        return self.pub_date.date() == datetime.date.today()
>
> Your indentation is wrong. was_published_today is an inner function of
> __str__ instead of being a class method of its own. 'def
> was_published_today' should have the same indentation as 'def __str__'
>
> Please be very careful with whitespace when writing python/django code!
>
> Btw, are you using version 0.96.x of Django or a SVN checkout? You
> should use __unicode__ instead of __str__ in code written for a current
> version of Django. This does not matter for the problem you run into,
> I'm just asking.
>
> Matthias
>
> --http://spinlock.ch/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to