DetailView iterating reverse ManyToMany objects
<p>Given the Django example in making queries:</p>

<pre><code>class Author(models.Model):
    name = models.CharField(max_length=50)
    ...
    def __str__(self):
        return self.name

class Entry(models.Model):
    ...
    authors = models.ManyToManyField(Author)
</code></pre>

<p>I'd like to have an author DetailView which contains a list of entries for that author. What I have so far:</p>

<pre><code>class AuthorDetailView(DetailView):
    model = Author

    def get_context_data(self, **kwargs):
        context = super(AuthorDetailView, self).get_context_data(**kwargs)
        context['entries'] = Entry.objects.filter(
            authors__name=self.object.name)
        return context
</code></pre>

<p>and in my template:</p>

<pre><code>{% for entry in entries %}
    …
{% endfor %}
</code></pre>

<p>I'd also prefer to not filter by name but that specific author since name could be non unique.</p>