Viewing posts by author

I tried the homework task of building views and templates for viewing posts by author, here's my attempt.

It works as intended but I'm not sure I've gone about it in a very good way. For example, I've had to repeat myself and type .filter(published=True) -rather than using the model manager's live method.

Perhaps inheriting from a generic view wasn't the best idea for AuthorDetailView?

My URL design I think means that you couldn't have a blog post called simply "authors", but perhaps that's not too much of a problem.

Any thoughts welcome

Sorry You must be a logged in, registered user to answer a question.

Answers

Going through it the way you have, through the foreign key, no, you won't be able to use .live().

Thanks, I see what you mean. http://codepad.org/ZcYrio9K I've kept everything the same apart from the way I retrieve the Post list, which is now Post.objects.live().filter(author__username=username)
myprecious on