On Tue, Jul 1, 2008 at 3:18 PM, [EMAIL PROTECTED] <[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()
>
>
Indentation is significant in Python.  You need to un-dent
was_published_today() so that it is indented just as far as the def
__str__(), not nested inside __str__().

Karen

--~--~---------~--~----~------------~-------~--~----~
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