diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index 538bf54..8982f76 100644
a
|
b
|
from django.core.exceptions import ImproperlyConfigured
|
12 | 12 | from django.utils.encoding import smart_unicode |
13 | 13 | from django.utils.translation import ugettext_lazy as _ |
14 | 14 | from django.utils import timezone |
15 | | |
16 | 15 | from django.contrib.admin.util import (get_model_from_relation, |
17 | 16 | reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value) |
| 17 | from django.contrib.admin.options import IncorrectLookupParameters |
18 | 18 | |
19 | 19 | class ListFilter(object): |
20 | 20 | title = None # Human-readable title to appear in the right sidebar. |
… |
… |
class FieldListFilter(ListFilter):
|
129 | 129 | return True |
130 | 130 | |
131 | 131 | def queryset(self, request, queryset): |
132 | | return queryset.filter(**self.used_parameters) |
| 132 | try: |
| 133 | return queryset.filter(**self.used_parameters) |
| 134 | except Exception as e: |
| 135 | raise IncorrectLookupParameters(e) |
133 | 136 | |
134 | 137 | @classmethod |
135 | 138 | def register(cls, test, list_filter_class, take_priority=False): |
diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py
index 01a19e6..a88c314 100644
a
|
b
|
class CustomArticleAdmin(admin.ModelAdmin):
|
127 | 127 | |
128 | 128 | |
129 | 129 | class ThingAdmin(admin.ModelAdmin): |
130 | | list_filter = ('color__warm', 'color__value') |
| 130 | list_filter = ('color__warm', 'color__value', 'pub_date',) |
131 | 131 | |
132 | 132 | |
133 | 133 | class InquisitionAdmin(admin.ModelAdmin): |
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index ab2bc20..e790537 100644
a
|
b
|
class Color2(Color):
|
118 | 118 | class Thing(models.Model): |
119 | 119 | title = models.CharField(max_length=20) |
120 | 120 | color = models.ForeignKey(Color, limit_choices_to={'warm': True}) |
| 121 | pub_date = models.DateField(blank=True, null=True) |
121 | 122 | def __unicode__(self): |
122 | 123 | return self.title |
123 | 124 | |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 49ec3c1..58857c9 100644
a
|
b
|
class AdminViewBasicTest(TestCase):
|
453 | 453 | response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'color__id__exact': 'StringNotInteger!'}) |
454 | 454 | self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit) |
455 | 455 | |
| 456 | # Regression test for #18530 |
| 457 | response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'pub_date__gte': 'foo'}) |
| 458 | self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit) |
| 459 | |
456 | 460 | def testIsNullLookups(self): |
457 | 461 | """Ensure is_null is handled correctly.""" |
458 | 462 | Article.objects.create(title="I Could Go Anywhere", content="Versatile", date=datetime.datetime.now()) |