On Sun, 2007-05-06 at 13:46 -0700, gsmith wrote:
> I have the following tables
>
> class members(models.Model):
> title = models.CharField(maxlength=100)
> names = models.CharField(maxlength=100)
> email = models.EmailField()
> city = models.CharField(maxlength=100)
> state = models.USStateField()
> image = models.ImageField(upload_to='c:/django/site_media/')
>
> class minutes(models.Model):
> date = models.DateField()
> lasted = models.IntegerField()
> lmembers = models.ManyToManyField(members)
> body = models.TextField(maxlength=5000)
>
> My minutes table has a 'ManyToManyField' called lmembers. I have
> created a minutes page that is supposed to show all the members tied
> to a minutes instance. I am not sure how to display the results of my
> 'ManyToManyField' in my template. I know how to show the other fields
> in minutes by {{ minutes.date }}, {{ minutes.lasted }}, etc...
> However, I don't know how to show the members tied to that minutes
> class.
The contents of lmembers is always going to be something that behaves
like a sequence (since there are "many" of them, by definition). So you
display them by iterating over that sequence. For example:
{{ for member in minutes.lmembers.all }}
{{ member }}
{{ endfor }}
The thing that most people forget or don't notice initially here is the
need for the call to the all() method to retrieve the collection that
you can iterate over.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---