mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Corrected the behavior of the SimpleFilter.lookups method to also be able to return None. Also modified example in documentation to be a bite more realistic. Refs #5833. Thanks for the hint, Martin Mahner.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16150 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
950e05c3ff
commit
05b4f2ebc2
3 changed files with 29 additions and 10 deletions
|
@ -607,15 +607,12 @@ subclass::
|
|||
class AuthDecadeBornListFilter(DecadeBornListFilter):
|
||||
|
||||
def lookups(self, request):
|
||||
if request.user.is_authenticated():
|
||||
return (
|
||||
('80s', 'in the eighties'),
|
||||
('other', 'other'),
|
||||
)
|
||||
else:
|
||||
return (
|
||||
('90s', 'in the nineties'),
|
||||
)
|
||||
if request.user.is_superuser:
|
||||
return super(AuthDecadeBornListFilter, self).lookups(request)
|
||||
|
||||
def queryset(self, request, queryset):
|
||||
if request.user.is_superuser:
|
||||
return super(AuthDecadeBornListFilter, self).queryset(request, queryset)
|
||||
|
||||
* a tuple, where the first element is a field name and the second
|
||||
element is a class inheriting from
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue