diff --git a/django/db/models/query.py b/django/db/models/query.py index 2e62b85602..bd2cf8dbaa 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -2,7 +2,7 @@ import warnings from django.db import connection, transaction from django.db.models.fields import DateField, FieldDoesNotExist -from django.db.models.query_utils import Q, EmptyResultSet, not_q +from django.db.models.query_utils import Q, not_q from django.db.models import signals, sql from django.dispatch import dispatcher from django.utils.datastructures import SortedDict @@ -12,6 +12,9 @@ from django.utils.datastructures import SortedDict CHUNK_SIZE = 100 ITER_CHUNK_SIZE = CHUNK_SIZE +# Pull into this namespace for backwards compatibility +EmptyResultSet = sql.EmptyResultSet + class _QuerySet(object): "Represents a lazy database lookup for a set of objects" def __init__(self, model=None, query=None): diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 003628ad94..6f1b860f21 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -9,12 +9,6 @@ from copy import deepcopy from django.utils import tree -class EmptyResultSet(Exception): - """ - Raised when a QuerySet cannot contain any data. - """ - pass - class QueryWrapper(object): """ A type that indicates the contents are an SQL fragment and the associate diff --git a/django/db/models/sql/__init__.py b/django/db/models/sql/__init__.py index ef8706c9df..7310982690 100644 --- a/django/db/models/sql/__init__.py +++ b/django/db/models/sql/__init__.py @@ -1,6 +1,7 @@ from query import * from subqueries import * from where import AND, OR +from datastructures import EmptyResultSet -__all__ = ['Query', 'AND', 'OR'] +__all__ = ['Query', 'AND', 'OR', 'EmptyResultSet']