Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote-tracking branch 'django/master' into t3011

  • Loading branch information...
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4 2 parents dbb3900 + 935a863
Russell Keith-Magee authored September 16, 2012
9  django/contrib/admin/filters.py
@@ -8,13 +8,13 @@
8 8
 import datetime
9 9
 
10 10
 from django.db import models
11  
-from django.core.exceptions import ImproperlyConfigured
  11
+from django.core.exceptions import ImproperlyConfigured, ValidationError
12 12
 from django.utils.encoding import smart_text
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.
@@ -129,7 +129,10 @@ def has_output(self):
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 ValidationError as e:
  135
+            raise IncorrectLookupParameters(e)
133 136
 
134 137
     @classmethod
135 138
     def register(cls, test, list_filter_class, take_priority=False):
5  django/contrib/auth/tests/views.py
... ...
@@ -1,7 +1,7 @@
1 1
 import os
2 2
 import re
3 3
 
4  
-from django.conf import settings
  4
+from django.conf import global_settings, settings
5 5
 from django.contrib.sites.models import Site, RequestSite
6 6
 from django.contrib.auth.models import User
7 7
 from django.core import mail
@@ -24,7 +24,8 @@
24 24
         ('en', 'English'),
25 25
     ),
26 26
     LANGUAGE_CODE='en',
27  
-    TEMPLATE_DIRS = (
  27
+    TEMPLATE_LOADERS=global_settings.TEMPLATE_LOADERS,
  28
+    TEMPLATE_DIRS=(
28 29
         os.path.join(os.path.dirname(__file__), 'templates'),
29 30
     ),
30 31
     USE_TZ=False,
7  django/test/signals.py
@@ -52,6 +52,13 @@ def clear_context_processors_cache(**kwargs):
52 52
 
53 53
 
54 54
 @receiver(setting_changed)
  55
+def clear_template_loaders_cache(**kwargs):
  56
+    if kwargs['setting'] == 'TEMPLATE_LOADERS':
  57
+        from django.template import loader
  58
+        loader.template_source_loaders = None
  59
+
  60
+
  61
+@receiver(setting_changed)
55 62
 def clear_serializers_cache(**kwargs):
56 63
     if kwargs['setting'] == 'SERIALIZATION_MODULES':
57 64
         from django.core import serializers
2  docs/ref/models/querysets.txt
@@ -1050,7 +1050,7 @@ defer
1050 1050
 In some complex data-modeling situations, your models might contain a lot of
1051 1051
 fields, some of which could contain a lot of data (for example, text fields),
1052 1052
 or require expensive processing to convert them to Python objects. If you are
1053  
-using the results of a queryset in some situation where you know you don't know
  1053
+using the results of a queryset in some situation where you don't know
1054 1054
 if you need those particular fields when you initially fetch the data, you can
1055 1055
 tell Django not to retrieve them from the database.
1056 1056
 
12  docs/topics/logging.txt
@@ -255,12 +255,12 @@ complex logging setup, configured using :meth:`logging.dictConfig`::
255 255
         },
256 256
         'handlers': {
257 257
             'null': {
258  
-                'level':'DEBUG',
259  
-                'class':'django.utils.log.NullHandler',
  258
+                'level': 'DEBUG',
  259
+                'class': 'django.utils.log.NullHandler',
260 260
             },
261 261
             'console':{
262  
-                'level':'DEBUG',
263  
-                'class':'logging.StreamHandler',
  262
+                'level': 'DEBUG',
  263
+                'class': 'logging.StreamHandler',
264 264
                 'formatter': 'simple'
265 265
             },
266 266
             'mail_admins': {
@@ -271,9 +271,9 @@ complex logging setup, configured using :meth:`logging.dictConfig`::
271 271
         },
272 272
         'loggers': {
273 273
             'django': {
274  
-                'handlers':['null'],
  274
+                'handlers': ['null'],
275 275
                 'propagate': True,
276  
-                'level':'INFO',
  276
+                'level': 'INFO',
277 277
             },
278 278
             'django.request': {
279 279
                 'handlers': ['mail_admins'],
2  tests/regressiontests/admin_views/admin.py
@@ -130,7 +130,7 @@ def changelist_view(self, request):
130 130
 
131 131
 
132 132
 class ThingAdmin(admin.ModelAdmin):
133  
-    list_filter = ('color__warm', 'color__value')
  133
+    list_filter = ('color__warm', 'color__value', 'pub_date',)
134 134
 
135 135
 
136 136
 class InquisitionAdmin(admin.ModelAdmin):
1  tests/regressiontests/admin_views/models.py
@@ -128,6 +128,7 @@ class Meta:
128 128
 class Thing(models.Model):
129 129
     title = models.CharField(max_length=20)
130 130
     color = models.ForeignKey(Color, limit_choices_to={'warm': True})
  131
+    pub_date = models.DateField(blank=True, null=True)
131 132
     def __str__(self):
132 133
         return self.title
133 134
 
4  tests/regressiontests/admin_views/tests.py
@@ -437,6 +437,10 @@ def testIncorrectLookupParameters(self):
437 437
         response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'color__id__exact': 'StringNotInteger!'})
438 438
         self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit)
439 439
 
  440
+        # Regression test for #18530
  441
+        response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'pub_date__gte': 'foo'})
  442
+        self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit)
  443
+
440 444
     def testIsNullLookups(self):
441 445
         """Ensure is_null is handled correctly."""
442 446
         Article.objects.create(title="I Could Go Anywhere", content="Versatile", date=datetime.datetime.now())
21  tests/regressiontests/views/tests/debug.py
... ...
@@ -1,36 +1,27 @@
1  
-from __future__ import absolute_import
  1
+from __future__ import absolute_import, unicode_literals
2 2
 
3 3
 import inspect
4 4
 import os
5 5
 import sys
6 6
 
7 7
 from django.conf import settings
  8
+from django.core import mail
8 9
 from django.core.files.uploadedfile import SimpleUploadedFile
9  
-from django.test import TestCase, RequestFactory
10  
-from django.test.utils import (setup_test_template_loader,
11  
-                               restore_template_loaders)
12 10
 from django.core.urlresolvers import reverse
  11
+from django.test import TestCase, RequestFactory
  12
+from django.test.utils import (override_settings, setup_test_template_loader,
  13
+    restore_template_loaders)
13 14
 from django.views.debug import ExceptionReporter
14  
-from django.core import mail
15 15
 
16 16
 from .. import BrokenException, except_args
17 17
 from ..views import (sensitive_view, non_sensitive_view, paranoid_view,
18 18
     custom_exception_reporter_filter_view, sensitive_method_view)
19 19
 
20 20
 
  21
+@override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
21 22
 class DebugViewTests(TestCase):
22 23
     urls = "regressiontests.views.urls"
23 24
 
24  
-    def setUp(self):
25  
-        self.old_debug = settings.DEBUG
26  
-        settings.DEBUG = True
27  
-        self.old_template_debug = settings.TEMPLATE_DEBUG
28  
-        settings.TEMPLATE_DEBUG = True
29  
-
30  
-    def tearDown(self):
31  
-        settings.DEBUG = self.old_debug
32  
-        settings.TEMPLATE_DEBUG = self.old_template_debug
33  
-
34 25
     def test_files(self):
35 26
         response = self.client.get('/raises/')
36 27
         self.assertEqual(response.status_code, 500)

0 notes on commit 280bf19

Please sign in to comment.
Something went wrong with that request. Please try again.