#743 closed defect (fixed)
new-admin: lookup_val2 not defined in BooleanFieldFilterSpec of django.contrib.admin.views.main
Reported by: | Owned by: | rjwittams | |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When attempting to filter on a boolean value in the new-admin admin interface, the following exception is thrown:
TemplateSyntaxError: While rendering at admin/filters, line 3 , caught exception: NameError: global name 'lookup_val2' is not defined
In django.contrib.admin.views.main
, the value lookup_val2
is not defined on line 194 in the output
method of class BooleanFieldFilterSpec
(at the equality test lookup_val2 == 'True'
):
def output(self, cl): t = [] t.append(_('<h3>By %s:</h3><ul>\n') % self.field.verbose_name) for k, v in (('All', None), ('Yes', '1'), ('No', '0')): t.append('<li%s><a href="%s">%s</a></li>\n' % \ (((self.lookup_val == v and not self.lookup_val2) and ' class="selected"' or ''), cl.get_query_string( {self.lookup_kwarg: v}, [self.lookup_kwarg2]), k)) if isinstance(self.field, meta.NullBooleanField): t.append('<li%s><a href="%s">%s</a></li>\n' % \ (((lookup_val2 == 'True') and ' class="selected"' or ''), cl.get_query_string( {self.lookup_kwarg2: 'True'}, [self.lookup_kwarg]), 'Unknown')) t.append('</ul>\n\n') return "".join(t)
It seems that changing lookup_val2
to self.lookup_val2
solves this issue.
Change History (4)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Owner: | changed from | to
---|
Realizing that I should probably assign this to rjwittams
since it's new-admin
.
comment:4 by , 17 years ago
Reporter: | changed from | to
---|
Note:
See TracTickets
for help on using tickets.
As of rev 1131, the relevant method is now
choices
:yield { 'selected' : lookup_val2 == 'True', is now the line with this issue.