From 777da5bc732348d2182ad0231e89b0cad1a79b5b Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Tue, 5 Jan 2010 04:12:09 +0000 Subject: [PATCH] Fixed a regression in validate_unique introduced in [12098]. Thanks, Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12099 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index 935933ae0e..af06ee1c12 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -715,9 +715,7 @@ class Model(object): if not getattr(self, '_adding', False) and self.pk is not None: qs = qs.exclude(pk=self.pk) - # This cute trick with extra/values is the most efficient way to - # tell if a particular query returns any results. - if qs.extra(select={'a': 1}).values('a').order_by(): + if qs.exists(): if len(unique_check) == 1: key = unique_check[0] else: