1. Josh VanderLinden
  2. django-reploc
Issue #1 new

Search for a location in admin generates an error: fix is at the bottom below

Paul Egges
created an issue

Search generates the following error

File "./lib/python2.5/django/db/models/fields/related.py", line 156, in get_db_prep_lookup raise TypeError, "Related Field has invalid lookup: %s" % lookup_type

TypeError: Related Field has invalid lookup: icontains

Fix the admin.py Line 7

{{{

!python

search_fields = ['representative', 'street1', 'street2', 'city', 'state', 'postal_code', 'country']

}}}

Should be

{{{

!python

search_fields = ['representative__name', 'street1', 'street2', 'city', 'state', 'postal_code', 'country']

}}} Because representative is a Foreign Key we need to specify the field(s) in the model to search. In this case the name.

Comments (2)

  1. Log in to comment