2009/10/12 Denis Bahati <djma...@gmail.com>

> Hi there i have the problem with unicode function it doesn't give me any
> changes. the poll list is displayed as Poll object and does doesn't give me
> error if i write the models.py like this:from django.db import models
> import datetime
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
> def __unicode__(self):
>  return self.question
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
> def was_published_today(self):
>     return self.pub_date.date() == datetime.date.today()
> was_published_today.short_description = 'Published today?'
>
> this identation makes functions live in module, not class. You should add
one ident to your methods to push them into class body like this:
class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    def __unicode__(self):
 return self.question
    def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
    def was_published_today(self):
        return self.pub_date.date() == datetime.date.today()

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to