1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

[soc2009/model-validation] Merget to trunk at r12009

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@12014 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Honza Král
2009-12-28 16:35:23 +00:00
parent 695de8cc91
commit f911df19a4
556 changed files with 22622 additions and 9561 deletions

View File

@@ -299,6 +299,18 @@ according to available IDs. You usually won't need to use this directly; a
primary key field will automatically be added to your model if you don't specify
otherwise. See :ref:`automatic-primary-key-fields`.
``BigIntegerField``
-------------------
.. versionadded:: 1.2
.. class:: BigIntegerField([**options])
A 64 bit integer, much like an :class:`IntegerField` except that it is
guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The
admin represents this as an ``<input type="text">`` (a single-line input).
``BooleanField``
----------------
@@ -543,7 +555,7 @@ By default, :class:`FileField` instances are
created as ``varchar(100)`` columns in your database. As with other fields, you
can change the maximum length using the :attr:`~CharField.max_length` argument.
.. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941
.. _`strftime formatting`: http://docs.python.org/library/time.html#time.strftime
``FilePathField``
-----------------

View File

@@ -1,5 +1,6 @@
.. _ref-models-index:
======
Models
======

View File

@@ -4,8 +4,9 @@
Model ``Meta`` options
======================
This document explains all the possible :ref:`metadata options <meta-options>` that you can give your model in its internal
``class Meta``.
This document explains all the possible :ref:`metadata options
<meta-options>` that you can give your model in its internal ``class
Meta``.
Available ``Meta`` options
==========================
@@ -242,4 +243,3 @@ The plural name for the object::
verbose_name_plural = "stories"
If this isn't given, Django will use :attr:`~Options.verbose_name` + ``"s"``.

View File

@@ -94,7 +94,7 @@ the query construction and is not part of the public API. However, it is safe
(and fully supported) to pickle and unpickle the attribute's contents as
described here.
.. _pickle: http://docs.python.org/lib/module-pickle.html
.. _pickle: http://docs.python.org/library/pickle.html
.. _queryset-api:
@@ -874,6 +874,24 @@ logically::
# existing set of fields).
Entry.objects.defer("body").only("headline", "body")
``using(alias)``
~~~~~~~~~~~~~~~~~~
.. versionadded:: 1.2
This method is for controlling which database the ``QuerySet`` will be
evaluated against if you are using more than one database. The only argument
this method takes is the alias of a database, as defined in
:setting:`DATABASES`.
For example::
# queries the database with the 'default' alias.
>>> Entry.objects.all()
# queries the database with the 'backup' alias
>>> Entry.objects.using('backup')
QuerySet methods that do not return QuerySets
---------------------------------------------
@@ -1019,7 +1037,8 @@ Example::
``count()`` performs a ``SELECT COUNT(*)`` behind the scenes, so you should
always use ``count()`` rather than loading all of the record into Python
objects and calling ``len()`` on the result.
objects and calling ``len()`` on the result (unless you need to load the
objects into memory anyway, in which case ``len()`` will be faster).
Depending on which database you're using (e.g. PostgreSQL vs. MySQL),
``count()`` may return a long integer instead of a normal Python integer. This
@@ -1112,6 +1131,20 @@ control the name of the aggregation value that is returned::
For an in-depth discussion of aggregation, see :ref:`the topic guide on
Aggregation <topics-db-aggregation>`.
``exists()``
~~~~~~~~~~~~
.. versionadded:: 1.2
Returns ``True`` if the :class:`QuerySet` contains any results, and ``False``
if not. This tries to perform the query in the simplest and fastest way
possible, but it *does* execute nearly the same query. This means that calling
:meth:`QuerySet.exists()` is faster than ``bool(some_query_set)``, but not by
a large degree. If ``some_query_set`` has not yet been evaluated, but you know
that it will be at some point, then using ``some_query_set.exists()`` will do
more overall work (an additional query) than simply using
``bool(some_query_set)``.
.. _field-lookups:
``exists()``