Hello,

If a user goes to domain.com/entries/ I'd like to show her a list of
all the entries she's created. I'm wrapping the generic list view in
function that filters the query set, like so:

from django.views.generic.list_detail import object_

urls.py

info_dict = {
    'queryset': Entry.objects.all(),
    'template_name': 'entry_list.html',
}

urlpatterns = patterns('',
    url(r'^entries/$', view_entry_list,  info_dict),
)

views.py

def view_entry_list(*args, **kwargs):
    request = args[0]
    kwargs['queryset'] = kwargs['queryset'].filter(user=request.user)
    return object_list(*args, **kwargs)

Is there a better way to write this?

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