Make sure that location_type has a __str__() and/or __unicode__()
field set, and it's returning a str.

Cory

On Jun 6, 8:18 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Excuse me for the dumb question.
>
> My model :
>
> class phonenumber(models.Model):
>     location_type = models.ForeignKey(location_type)
>     location_description = models.CharField(max_length=50, blank=True)
>
>     def __unicode__(self):
>         if self.location_description:
>             retval = self.location_description + ' - '
>         else:
>             retval = self.location_type + ' - '
>         return retval
>
>     class Meta:
>         app_label = 'contacts'
>
> I get an error saying :
> TypeError at /contacts/phonenumber/
> unsupported operand type(s) for +: 'location_type' and 'str'
>
> How do I get the location_type __unicode__ for the fk?
>
> Thanks in advance
>
> Regards Ganesh
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to