﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21129	Little change of admin filter URL throws AttributeError	Vlada Macek	Tim Schilling	"A list_filter for FK creates a query string {{{<field>__id__exact}}}. Changing 'exact' to anything else appears to throw:

    AttributeError: 'NoneType' object has no attribute 'to'

Tested on 1.5.4 and 1.4.x.

{{{
.../django/contrib/admin/options.py in lookup_allowed
                try:
                    field, _, _, _ = model._meta.get_field_by_name(part)
                except FieldDoesNotExist:
                    # Lookups on non-existent fields are ok, since they're ignored
                    # later.
                    return True
                if hasattr(field, 'rel'):
>>>                 model = field.rel.to
                    rel_name = field.rel.get_related_field().name
                elif isinstance(field, RelatedObject):
                    model = field.model
                    rel_name = model._meta.pk.name
                else:
                    rel_name = None

▼ Local vars
Variable 	Value
rel_name 	u'id'
self 	<project.apps.calendar.admin.BusyAdmin object at 0xb523768c>
parts 	[u'site', u'id', u'anything']
value 	u'5'
field 	<django.db.models.fields.AutoField: id>
part 	u'id'
lookup 	u'site__id__anything'
model 	<class 'django.contrib.sites.models.Site'>
_ 	False
}}}"	Bug	closed	contrib.admin	1.5	Normal	fixed		schillingt@…	Accepted	1	0	0	0	0	0
