Opened 17 years ago

Closed 17 years ago

#4905 closed (invalid)

__unicode__

Reported by: Alexander.Suvorov@… Owned by: Jacob
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi
Beginner question. Is there any reason why def unicode(self): do not work ?

n= Poll(question="What's up dude ?", pub_date=datetime.now())

n.save()

Poll.objects.get(pk=1)

<Poll: Poll object>

from django.db import models
import datetime

class Poll(models.Model):

question = models.CharField(maxlength=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()

class Choice(models.Model):

poll = models.ForeignKey(Poll)
choice = models.CharField(maxlength=200)
votes = models.IntegerField()

def unicode(self):

return self.choice

Thanks in advance
Alex

Change History (1)

comment:1 by Thomas Steinacher <tom@…>, 17 years ago

Resolution: invalid
Status: newclosed

You're probably not using the latest SVN version. 0.96 doesn't support this. Please ask such questions in future on the django-users mailing list.

Note: See TracTickets for help on using tickets.
Back to Top