On Mon, Jul 20, 2009 at 2:00 PM, AKK<andrewkenyon...@gmail.com> wrote: > > I kinda know what the problem is here but don't know how to fix it. > > I have this model class Comment(models.Model): > > comment_post = models.ForeignKey('Post') > comment_date = models.DateTimeField('Date comment made') > comment_body = models.TextField() > comment_spam = models.BooleanField(default=False) > comment_author = models.CharField(max_length=5000) > > def __unicode__(self): > return self.comment_post > > and when i true to add a comment using the admin pages i get : > > coercing to Unicode: need string or buffer, Post found > > presuambly this is something to do with return self.comment_post but > what should i do to fix it > > thanks > > >
To fix it you can just return unicode(self.comment_post). This will return the unicode coersion of the comment_post, which is presumabley what you were intending. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Voltaire "The people's good is the highest law." -- Cicero "Code can always be simpler than you think, but never as simple as you want" -- Me --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---