On 7/21/07, jeffself <[EMAIL PROTECTED]> wrote: > > How do I get the season to > display in the select box of my season field on the Game form? > Normally this would be fixed by using def __unicode__(self) but since > its not a CharField, I can't use that. I tried def __integer__(self) > but that didn't make a difference.
You were on the right track with __unicode__(). __unicode__ is the instructions to Python as to how to produce a human-readable representation of this object (in unicode). I'm guessing what you tried was: def __unicode__(self): return self.year which failed. This failed because what you are returning is an integer, not a unicode string, so when the return value is combined with other strings it raises an error. However, if you make a slight change to convert the year into a string before it is returned: def __unicode__(self): return unicode(self.year) Everything should work nicely. You can even get creative, and add in other bits of text: def __unicode__(self): return unicode(self.year) + u" Season" So that what gets display isn't just a year, but "1999 Season". Hope this helps. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---