I’m going through the Django framework assessment by myself and discovered that in the officially posted code, they created a rather complicated view to give all the blogs an author created. The class defined is here.
Why can’t I just write it as follows?
class AuthorDetailView(generic.DetailView):
model = Author
and in the template
{% for post in author.post_set.all %}
<li><b class="term"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
({{ post.date }})</b></li>
{% endfor %}
since in the model we’ve already defined in Meta that the sorting of the posts is based on date. In this way, I don’t need to overwrite get_queryset() and get_context_data().