From 2ce78063fa07ee3ebbae6eb5c00cc251b89da66f Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 29 Aug 2005 16:44:40 +0000 Subject: [PATCH] Fixed bug in metasystem manipulator_validator_unique_for_date(), related to [549] git-svn-id: http://code.djangoproject.com/svn/django/trunk@571 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/meta/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index ea68ca59f9..9d807ed892 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -1613,7 +1613,11 @@ def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_t date_val = formfields.DateField.html2python(date_str) if date_val is None: return # Date was invalid. This will be caught by another validator. - lookup_kwargs = {'%s__iexact' % from_field.name: field_data, '%s__year' % date_field.name: date_val.year} + lookup_kwargs = {'%s__year' % date_field.name: date_val.year} + if isinstance(from_field.rel, ManyToOne): + lookup_kwargs['%s__pk' % from_field.name] = field_data + else: + lookup_kwargs['%s__iexact' % from_field.name] = field_data if lookup_type in ('month', 'date'): lookup_kwargs['%s__month' % date_field.name] = date_val.month if lookup_type == 'date':