On Mon, Mar 15, 2010 at 6:07 AM, BobAalsma <b...@leaddevice.com> wrote:
> I get a TypeError at Post from the admin interface and I suspect this > is connected to my key definition, but couldn't find documentation on > this. > > Any ideas? > > Error message: > TypeError at /admin/LeadDeviceSysteem/vraagcomponentinhoud/add/ > coercing to Unicode: need string or buffer, VraagComponentModel found > Request Method: POST > Request URL: > http://127.0.0.1:8000/admin/LeadDeviceSysteem/vraagcomponentinhoud/add/ > Exception Type: TypeError > Exception Value: coercing to Unicode: need string or buffer, > VraagComponentModel found > > This coercing exception is almost always due to an incorrect __unicocde__ method definition. A __unicode__ method must return unicode (or string or buffer, which can be coerced to unicode). Instead this one is returning a VraagComponentModel: [snip] > class VraagComponentInhoud(models.Model): > componentModel = models.ForeignKey(VraagComponentModel) > [snip] > def __unicode__(self): > return self.componentModel > > If you want to return the unicode representation of that ForeignKey, you need to return unicode(self.componentModel). 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-us...@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.