#19182: ModelAdmin.lookup_allowed should also check for ('fieldname', ClassName)
syntax
-------------------------------+---------------------------------------
     Reporter:  gauss          |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  contrib.admin  |    Version:  1.4
     Severity:  Normal         |   Keywords:  modeladmin lookup_allowed
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+---------------------------------------
 Admin raises SuspiciousOperation on using complex query like
 {{{ghi__jkl__contains}}} in custom list filter described by
 {{{('fieldpath', ClassName )}}} syntax.

 {{{#!python
 class MyModelAdmin(ModelAdmin):
     ...
     list_filter = (
         'abc', 'def',
         ( 'ghi__jkl__contains', MyListFilter )
     )
     ...
 }}}

 Simple but ugly fix by replacing last line of
 {{{ModelAdmin.lookup_allowed}}} (around line 270 in
 contrib/admin/options.py):

 {{{#!diff
         clean_lookup = LOOKUP_SEP.join(parts)
         --- return clean_lookup in self.list_filter or clean_lookup ==
 self.date_hierarchy
         +++ return any([ ( clean_lookup == ( i[0] if isinstance(i, tuple)
 else i ) ) for i in self.list_filter ]) or clean_lookup ==
 self.date_hierarchy
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19182>
Django <https://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 https://groups.google.com/groups/opt_out.


Reply via email to