Wow, thanks for the reply. I can't get this to work though--I get an
"iteration over non-sequence". Can you take a look?

model...

class Author(models.Model):
        first_name = models.CharField(maxlength=30)
        last_name = models.CharField(maxlength=40)

        def __str__(self):
                return '%s %s' % (self.first_name, self.last_name)

class Book(models.Model):
        title = models.CharField(maxlength=100)
        authors = models.ManyToManyField(Author)

        def __str__(self):
                return self.title

view...

def authors(request):
        a = Author.objects.all()
        return render_to_response('books/authors.html', {'authors':a,})

template...

<ul>
{% for author in authors %}
        <li>{{ author }}</a>

        <ul>
        {% for book in author.book_set %}
        {{ book }}{% if forloop.last %}{% else %}, {% endif %}
        {% endfor %}
        </ul>

        </li>
{% endfor %}
</ul>


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