Hi,

Is that code all that's in your model classes, or just an excerpt? If you
don't already have a __unicode__() method defined on your model, I think
that would cause the problem you are referring to. That method would be
called by Django in various places, wherever it needs to represent a model
object as a string.

Try:

class Interests(models.Model):
   # eg hockey, gaming, etc
   interest = models.CharField(max_length=100)
   class Meta:
       db_table = u'interests'

    def __unicode__(self):
            return self.interest

Hope that's helpful.

Best,
Patrick


On Sun, Feb 12, 2012 at 6:06 AM, richard <pullenjenn...@gmail.com> wrote:

> Hi im having difficulty looping over my mantomany in my template. A
> user has a 1to1 with UserProfile and the UserProfile has a manytomany
> with interests. But displaying the form field without looping over it
> displays a model multiple select with just a list of object result
> sets. displaying interests object in the list.
>
> code
> models.py
>
> class Interests(models.Model):
>    # eg hockey, gaming, etc
>    interest = models.CharField(max_length=100)
>    class Meta:
>        db_table = u'interests'
>
> class UserProfile(models.Model):
>    user = models.OneToOneField(User)
>    interests = models.ManyToManyField(Interests)
>
> ...

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

Reply via email to