#15517: Admin search_field prefixes conflict with db.models.get_field_by_name
---------------------------------------+------------------------------------
Reporter: fabianbuechler | Owner: nobody
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: 1.3-beta
Keywords: search_fields, changelist | Triage Stage: Unreviewed
Has patch: 1 |
---------------------------------------+------------------------------------
This issue might be related to #15203 and to the changeset r3601.
In the Django admin, the {{{ModelAdmin.search_fields}}} prefixes ({{{^, =,
@}}}) are converted to {{{__istartswith, __iexact and __search}}}
respectively in line 258 in {{{django.contrib.admin.views.main}}}:
{{{
or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for
field_name in self.search_fields]
}}}
A few lines below in line 263 the field names are passed to
{{{django.db.models.options.Options.get_field_by_name}}} without stripping
the search prefixes first:
{{{
f = self.lookup_opts.get_field_by_name(field_name)[0]
}}}
This results in {{{FieldNotFound}}} errors like "Event has no field named
'=slug'".
I've attached a working patch.
--
Ticket URL: <http://code.djangoproject.com/ticket/15517>
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.