From 51836756d01ab8fb4d98d913c01b61d91962a806 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 29 Aug 2008 22:29:38 +0000 Subject: [PATCH] Fixed a typo from the refactoring in [8455]. With bonus test, too. Thanks, vung. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8724 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/query.py | 2 +- tests/regressiontests/queries/models.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/db/models/query.py b/django/db/models/query.py index 655f87a482..4fe185ed6e 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -737,7 +737,7 @@ class DateQuerySet(QuerySet): self.query.select = [] field = self.model._meta.get_field(self._field_name, many_to_many=False) assert isinstance(field, DateField), "%r isn't a DateField." \ - % field_name + % field.name self.query.add_date_select(field, self._kind, self._order) if field.null: self.query.add_filter(('%s__isnull' % field.name, False)) diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index c524c6250e..d96f1de859 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -901,6 +901,12 @@ Pickling of DateQuerySets used to fail >>> qs = Item.objects.dates('created', 'month') >>> _ = pickle.loads(pickle.dumps(qs)) +Bug #8683 -- raise proper error when a DateQuerySet gets passed a wrong type of field +>>> Item.objects.dates('name', 'month') +Traceback (most recent call last): +... +AssertionError: 'name' isn't a DateField. + Bug #8597: regression tests for case-insensitive comparisons >>> _ = Item.objects.create(name="a_b", created=datetime.datetime.now(), creator=a2, note=n1) >>> _ = Item.objects.create(name="x%y", created=datetime.datetime.now(), creator=a2, note=n1)