#9222: Allow callable queryset in generic views
----------------------------------------+-----------------------------------
Reporter: [EMAIL PROTECTED] | Owner: nobody
Status: new | Milestone: post-1.0
Component: Generic views | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 1 |
----------------------------------------+-----------------------------------
I need to pass a variable queryset based on some external condition
(i.e. it can be Entry.objects.all() or Entry.objects.filter(...) or
other), but with current implementation it is impossible,
because generic views want a queryset, which is set indefinitely (I'm
thinking about the use in urls.py, not in
custom views).
Actually I wrote a simple wrapper, as
{{{
def obj_list(request, queryset, ...):
if callable(queryset):
queryset = queryset()
return object_list(request, queryset, ...)
...
}}}
and pass a function which returns the queryset I need.
I found it could be useful if it is included directly in the generic views
function.
The attached patch adds this functionality, and it doesn't break any
previous code.
--
Ticket URL: <http://code.djangoproject.com/ticket/9222>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---