summaryrefslogtreecommitdiff
path: root/django/db/models/base.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-10-24 00:28:39 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-10-24 00:28:39 +0000
commitb79702b2deec4ca3c625e5bffe46fa976c3c4e5f (patch)
tree2031b1d908ca03f650669b04effee8a872632e86 /django/db/models/base.py
parent9f70783b149105dfd37027504976f9526caeeae0 (diff)
Fixed #11402: added a `QuerySet.exists()` method. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11646 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/base.py')
-rw-r--r--django/db/models/base.py9
1 files changed, 1 insertions, 8 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index a5c99865a6..1e081ae92e 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -3,11 +3,6 @@ import types
import sys
import os
from itertools import izip
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback.
-
import django.db.models.manager # Imported to register signal handler.
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError
from django.db.models.fields import AutoField, FieldDoesNotExist
@@ -22,7 +17,6 @@ from django.utils.functional import curry
from django.utils.encoding import smart_str, force_unicode, smart_unicode
from django.conf import settings
-
class ModelBase(type):
"""
Metaclass for all models.
@@ -236,7 +230,6 @@ class ModelBase(type):
signals.class_prepared.send(sender=cls)
-
class Model(object):
__metaclass__ = ModelBase
_deferred = False
@@ -467,7 +460,7 @@ class Model(object):
if pk_set:
# Determine whether a record with the primary key already exists.
if (force_update or (not force_insert and
- manager.filter(pk=pk_val).extra(select={'a': 1}).values('a').order_by())):
+ manager.filter(pk=pk_val).exists())):
# It does already exist, so do an UPDATE.
if force_update or non_pks:
values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks]