I apologize in advance if this is a stupid question - I'm new to
Django, and a little over my head (but loving it!)

I'm trying to return a field from a foreign key relationship as part of
my __str__ method. When I do, I get this output in the admin interface:

Product Name - <django.db.models.fields.related.ManyRelatedManager
object at 0x014F5C30>

What am I doing wrong?

Code:

class Product(models.Model):
    name = models.CharField(maxlength=100)
    category = models.ManyToManyField(Category)
    ...
   def __str__(self):
        return '%s - %s' % (self.name, self.category)

class Category(models.Model):
    name = models.CharField(maxlength=100)
   def __str__(self):
        return self.name


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to