mirror of
https://github.com/django/django.git
synced 2025-07-06 02:39:12 +00:00
magic-removal: Merged to [2574]
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2575 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
652a05777e
commit
02b3ed3a1c
@ -48,7 +48,6 @@ class Manager(object):
|
|||||||
return QuerySet(self.model)
|
return QuerySet(self.model)
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
# Returns a caching QuerySet.
|
|
||||||
return self.get_query_set()
|
return self.get_query_set()
|
||||||
|
|
||||||
def count(self):
|
def count(self):
|
||||||
|
@ -232,23 +232,23 @@ class QuerySet(object):
|
|||||||
del_query._select_related = False
|
del_query._select_related = False
|
||||||
del_query._order_by = []
|
del_query._order_by = []
|
||||||
|
|
||||||
# Delete objects in chunks to prevent an the list of
|
# Delete objects in chunks to prevent an the list of
|
||||||
# related objects from becoming too long
|
# related objects from becoming too long
|
||||||
more_objects = True
|
more_objects = True
|
||||||
while more_objects:
|
while more_objects:
|
||||||
# Collect all the objects to be deleted in this chunk, and all the objects
|
# Collect all the objects to be deleted in this chunk, and all the objects
|
||||||
# that are related to the objects that are to be deleted
|
# that are related to the objects that are to be deleted
|
||||||
seen_objs = SortedDict()
|
seen_objs = SortedDict()
|
||||||
more_objects = False
|
more_objects = False
|
||||||
for object in del_query[0:GET_ITERATOR_CHUNK_SIZE]:
|
for object in del_query[0:GET_ITERATOR_CHUNK_SIZE]:
|
||||||
more_objects = True
|
more_objects = True
|
||||||
object._collect_sub_objects(seen_objs)
|
object._collect_sub_objects(seen_objs)
|
||||||
|
|
||||||
# If one or more objects were found, delete them.
|
# If one or more objects were found, delete them.
|
||||||
# Otherwise, stop looping.
|
# Otherwise, stop looping.
|
||||||
if more_objects:
|
if more_objects:
|
||||||
delete_objects(seen_objs)
|
delete_objects(seen_objs)
|
||||||
|
|
||||||
# Clear the result cache, in case this QuerySet gets reused.
|
# Clear the result cache, in case this QuerySet gets reused.
|
||||||
self._result_cache = None
|
self._result_cache = None
|
||||||
delete.alters_data = True
|
delete.alters_data = True
|
||||||
@ -278,12 +278,12 @@ class QuerySet(object):
|
|||||||
|
|
||||||
def filter(self, *args, **kwargs):
|
def filter(self, *args, **kwargs):
|
||||||
"Returns a new QuerySet instance with the args ANDed to the existing set."
|
"Returns a new QuerySet instance with the args ANDed to the existing set."
|
||||||
return self._filter_or_exclude(Q, *args, **kwargs)
|
return self._filter_or_exclude(Q, *args, **kwargs)
|
||||||
|
|
||||||
def exclude(self, *args, **kwargs):
|
def exclude(self, *args, **kwargs):
|
||||||
"Returns a new QuerySet instance with NOT (arsg) ANDed to the existing set."
|
"Returns a new QuerySet instance with NOT (arsg) ANDed to the existing set."
|
||||||
return self._filter_or_exclude(QNot, *args, **kwargs)
|
return self._filter_or_exclude(QNot, *args, **kwargs)
|
||||||
|
|
||||||
def _filter_or_exclude(self, qtype, *args, **kwargs):
|
def _filter_or_exclude(self, qtype, *args, **kwargs):
|
||||||
if len(args) > 0 or len(kwargs) > 0:
|
if len(args) > 0 or len(kwargs) > 0:
|
||||||
assert self._limit is None and self._offset is None, \
|
assert self._limit is None and self._offset is None, \
|
||||||
@ -558,7 +558,7 @@ class Q(object):
|
|||||||
|
|
||||||
class QNot(Q):
|
class QNot(Q):
|
||||||
"Encapsulates NOT (...) queries as objects"
|
"Encapsulates NOT (...) queries as objects"
|
||||||
|
|
||||||
def get_sql(self, opts):
|
def get_sql(self, opts):
|
||||||
tables, joins, where, params = super(QNot, self).get_sql(opts)
|
tables, joins, where, params = super(QNot, self).get_sql(opts)
|
||||||
where2 = ['(NOT (%s))' % " AND ".join(where)]
|
where2 = ['(NOT (%s))' % " AND ".join(where)]
|
||||||
@ -827,7 +827,7 @@ def delete_objects(seen_objs):
|
|||||||
"Iterate through a list of seen classes, and remove any instances that are referred to"
|
"Iterate through a list of seen classes, and remove any instances that are referred to"
|
||||||
ordered_classes = seen_objs.keys()
|
ordered_classes = seen_objs.keys()
|
||||||
ordered_classes.reverse()
|
ordered_classes.reverse()
|
||||||
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
for cls in ordered_classes:
|
for cls in ordered_classes:
|
||||||
|
@ -78,7 +78,7 @@ send_mass_mail vs. send_mail
|
|||||||
|
|
||||||
The main difference between ``send_mass_mail()`` and ``send_mail()`` is that
|
The main difference between ``send_mass_mail()`` and ``send_mail()`` is that
|
||||||
``send_mail()`` opens a connection to the mail server each time it's executed,
|
``send_mail()`` opens a connection to the mail server each time it's executed,
|
||||||
while ``send_mass_mail()`` uses a single connection for each of its messages.
|
while ``send_mass_mail()`` uses a single connection for all of its messages.
|
||||||
This makes ``send_mass_mail()`` slightly more efficient.
|
This makes ``send_mass_mail()`` slightly more efficient.
|
||||||
|
|
||||||
The mail_admins function
|
The mail_admins function
|
||||||
|
@ -51,9 +51,9 @@ make sure a database server is running. Django works with PostgreSQL_
|
|||||||
Additionally, you'll need to make sure your Python database bindings are
|
Additionally, you'll need to make sure your Python database bindings are
|
||||||
installed.
|
installed.
|
||||||
|
|
||||||
* If you're using PostgreSQL, you'll need the psycopg_ package (version 1 --
|
* If you're using PostgreSQL, you'll need the psycopg_ package (version 1.1 --
|
||||||
not version 2, which is still in beta). If you're on Windows, check out the
|
not version 1.0 or version 2, which is still in beta). If you're on Windows,
|
||||||
unofficial `compiled Windows version`_.
|
check out the unofficial `compiled Windows version`_.
|
||||||
* If you're using MySQL, you'll need MySQLdb_.
|
* If you're using MySQL, you'll need MySQLdb_.
|
||||||
* If you're using SQLite, you'll need pysqlite_. Use version 2.0.3 or higher.
|
* If you're using SQLite, you'll need pysqlite_. Use version 2.0.3 or higher.
|
||||||
|
|
||||||
|
@ -316,8 +316,8 @@ If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every
|
|||||||
representing the permissions that the currently logged-in user has. See
|
representing the permissions that the currently logged-in user has. See
|
||||||
the `permissions docs`_.
|
the `permissions docs`_.
|
||||||
|
|
||||||
.. _user authentication docs: http://www.djangoproject.com/documentation/models/authentication/#users
|
.. _user authentication docs: http://www.djangoproject.com/documentation/authentication/#users
|
||||||
.. _permissions docs: http://www.djangoproject.com/documentation/models/authentication/#permissions
|
.. _permissions docs: http://www.djangoproject.com/documentation/authentication/#permissions
|
||||||
|
|
||||||
django.core.context_processors.debug
|
django.core.context_processors.debug
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Loading…
x
Reference in New Issue
Block a user