Hi all -

As the subject suggests, I've wrapped the generic view
date_based.object_detail in another view, and while my solution seem
to be working, as I'm still new to Django, I'd like to check I'm doing
things right with the experts (you!).

I'm creating a blog that has multiple authors.  The url for posts is
date based but also includes the author's username, like:

domain.com/username/blog/2009/may/02/blog-post/

The view I've created consists of the following...

def post_detail(request, username, year, month, day, slug):
        return date_based.object_detail(request,
                                                                        year,
                                                                        month,
                                                                        day,
                                                                        
Post.objects.filter(author__username__exact=username),
                                                                        
date_field='pub_date',
                                                                        
slug=slug,
                                                                        
slug_field='slug',
                                                                        
extra_context={},
                                                                        
template_name='blog/post_detail.html')

It seems to work but as I say I'm still new to Django and I'm not sure
if this the right way to go around it.

As an alternative I could create a method (get_by_author) in my
manager that does the filtering which I'd be able to reuse in the
object_list view, such as:

def post_detail(request, username, year, month, day, slug):
        user = get_object_or_404(User, username__exact=username)
        return date_based.object_detail(request,
                                                                        year,
                                                                        month,
                                                                        day,
                                                                        
Post.objects.get_by_author(user.username),
                                                                        
date_field='pub_date',
                                                                        
slug=slug,
                                                                        
slug_field='slug',
                                                                        
extra_context={'user': user},
                                                                        
template_name='blog/post_detail.html')

Basically, am I doing things right, and if so which is the best
solution from the above?

Thanks in advance,
Jamie

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to