Skip to content

Empty "page" breaks search #2

Open
mbaechtold opened this Issue Oct 20, 2011 · 2 comments

2 participants

@mbaechtold

If you don't specify a "page" when creating a new redirect, the search filter in django admin will throw an error.

Here's the traceback:

Traceback (most recent call last):

File "/some/path//lib/python2.6/site-packages/django/core/handlers/base.py", line 100, in get_response
response = callback(request, callback_args, *callback_kwargs)

File "/some/path//lib/python2.6/site-packages/django/contrib/admin/options.py", line 288, in wrapper
return self.admin_site.admin_view(view)(args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/utils/decorators.py", line 76, in _wrapped_view
response = view_func(request, args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/views/decorators/cache.py", line 78, in _wrapped_view_func
response = view_func(request, args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/contrib/admin/sites.py", line 190, in inner
return view(request, args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/utils/decorators.py", line 21, in _wrapper
return decorator(bound_func)(args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/utils/decorators.py", line 76, in _wrapped_view
response = view_func(request, args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/utils/decorators.py", line 17, in bound_func
return func(self, args2, *kwargs2)

File "/some/path//lib/python2.6/site-packages/django/contrib/admin/options.py", line 1026, in changelist_view
self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)

File "/some/path//lib/python2.6/site-packages/django/contrib/admin/views/main.py", line 64, in init
self.query_set = self.get_query_set()

File "/some/path//lib/python2.6/site-packages/django/contrib/admin/views/main.py", line 244, in get_query_set
qs = qs.filter(reduce(operator.or_, or_queries))

File "/some/path//lib/python2.6/site-packages/django/db/models/query.py", line 561, in filter
return self._filter_or_exclude(False, args, *kwargs)

File "/some/path//lib/python2.6/site-packages/django/db/models/query.py", line 579, in _filter_or_exclude
clone.query.add_q(Q(args, *kwargs))

File "/some/path//lib/python2.6/site-packages/django/db/models/sql/query.py", line 1167, in add_q
self.add_q(child, used_aliases, force_having=force_having)

File "/some/path//lib/python2.6/site-packages/django/db/models/sql/query.py", line 1170, in add_q
can_reuse=used_aliases, force_having=force_having)

File "/some/path//lib/python2.6/site-packages/django/db/models/sql/query.py", line 1105, in add_filter
connector)

File "/some/path//lib/python2.6/site-packages/django/db/models/sql/where.py", line 67, in add
value = obj.prepare(lookup_type, value)

File "/some/path//lib/python2.6/site-packages/django/db/models/sql/where.py", line 316, in prepare
return self.field.get_prep_lookup(lookup_type, value)

File "/some/path//lib/python2.6/site-packages/django/db/models/fields/related.py", line 139, in get_prep_lookup
raise TypeError("Related Field has invalid lookup: %s" % lookup_type)

TypeError: Related Field has invalid lookup: icontains

@mbaechtold

One solution would be to use 'page__title_set__title' in the search fields.

@rfeldbinder

I fixed it in my fork and will create a pull request for it.
ableton-web/django-cms-redirects@5abbcd8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.