summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 23:34:03 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 23:34:03 +0000
commit516051bfd2b537f441c46359cce7eacbf15fc4b8 (patch)
treec518cb5727dcbbdeec08bf849e94bdfa7b5e36a7 /docs/ref/models
parent15becf23a9e4c9b230745738d2d42f6ab8f0f031 (diff)
A whole lotta documentation fixes: Fixes #8704, #8826, #8980, #9243, #9343, #9529,
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/fields.txt40
-rw-r--r--docs/ref/models/querysets.txt14
-rw-r--r--docs/ref/models/relations.txt2
3 files changed, 34 insertions, 22 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 62127884b6..42a44bf920 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -7,6 +7,8 @@ Model field reference
.. module:: django.db.models.fields
:synopsis: Built-in field types.
+.. currentmodule:: django.db.models
+
This document contains all the gory details about all the `field options`_ and
`field types`_ Django's got to offer.
@@ -45,11 +47,11 @@ booleans and dates. For both types of fields, you will also need to set
:attr:`~Field.blank`).
Avoid using :attr:`~Field.null` on string-based fields such as
-:class:`~django.db.models.CharField` and :class:`~django.db.models.TextField`
-unless you have an excellent reason. If a string-based field has ``null=True``,
-that means it has two possible values for "no data": ``NULL``, and the empty
-string. In most cases, it's redundant to have two possible values for "no
-data;" Django convention is to use the empty string, not ``NULL``.
+:class:`CharField` and :class:`TextField` unless you have an excellent reason.
+If a string-based field has ``null=True``, that means it has two possible values
+for "no data": ``NULL``, and the empty string. In most cases, it's redundant to
+have two possible values for "no data;" Django convention is to use the empty
+string, not ``NULL``.
.. note::
@@ -142,9 +144,8 @@ documentation.
Finally, note that choices can be any iterable object -- not necessarily a list
or tuple. This lets you construct choices dynamically. But if you find yourself
hacking :attr:`~Field.choices` to be dynamic, you're probably better off using a
-proper database table with a :class:`~django.db.models.ForeignKey`.
-:attr:`~Field.choices` is meant for static data that doesn't change much, if
-ever.
+proper database table with a :class:`ForeignKey`. :attr:`~Field.choices` is
+meant for static data that doesn't change much, if ever.
``db_column``
-------------
@@ -220,10 +221,10 @@ Alternatively you can use plain text and
If ``True``, this field is the primary key for the model.
If you don't specify ``primary_key=True`` for any fields in your model, Django
-will automatically add an :class:`~django.db.models.IntegerField` to hold the
-primary key, so you don't need to set ``primary_key=True`` on any of your
-fields unless you want to override the default primary-key behavior. For more,
-see :ref:`automatic-primary-key-fields`.
+will automatically add an :class:`IntegerField` to hold the primary key, so you
+don't need to set ``primary_key=True`` on any of your fields unless you want to
+override the default primary-key behavior. For more, see
+:ref:`automatic-primary-key-fields`.
``primary_key=True`` implies :attr:`null=False <Field.null>` and :attr:`unique=True <Field.unique>`.
Only one primary key is allowed on an object.
@@ -240,18 +241,16 @@ you try to save a model with a duplicate value in a :attr:`~Field.unique`
field, a :exc:`django.db.IntegrityError` will be raised by the model's
:meth:`~django.db.models.Model.save` method.
-This option is valid on all field types except
-:class:`~django.db.models.ManyToManyField` and
-:class:`~django.db.models.FileField`.
+This option is valid on all field types except :class:`ManyToManyField` and
+:class:`FileField`.
``unique_for_date``
-------------------
.. attribute:: Field.unique_for_date
-Set this to the name of a :class:`~django.db.models.DateField` or
-:class:`~django.db.models.DateTimeField` to require that this field be unique
-for the value of the date field.
+Set this to the name of a :class:`DateField` or :class:`DateTimeField` to
+require that this field be unique for the value of the date field.
For example, if you have a field ``title`` that has
``unique_for_date="pub_date"``, then Django wouldn't allow the entry of two
@@ -734,7 +733,10 @@ A :class:`CharField` for a URL. Has one extra optional argument:
.. attribute:: URLField.verify_exists
If ``True`` (the default), the URL given will be checked for existence
- (i.e., the URL actually loads and doesn't give a 404 response).
+ (i.e., the URL actually loads and doesn't give a 404 response). It should
+ be noted that when using the single-threaded development server, validating
+ a url being serverd by the same server will hang.
+ This should not be a problem for multithreaded servers.
The admin represents this as an ``<input type="text">`` (a single-line input).
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 847cebf1e9..4124e78513 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -154,7 +154,7 @@ In SQL terms, that evaluates to::
SELECT ...
WHERE NOT pub_date > '2005-1-3'
- AND NOT headline = 'Hello'
+ OR NOT headline = 'Hello'
Note the second example is more restrictive.
@@ -1484,8 +1484,18 @@ search
A boolean full-text search, taking advantage of full-text indexing. This is
like ``contains`` but is significantly faster due to full-text indexing.
+Example::
+
+ Entry.objects.filter(headline__search="+Django -jazz Python")
+
+SQL equivalent::
+
+ SELECT ... WHERE MATCH(tablename, headline) AGAINST (+Django -jazz Python IN BOOLEAN MODE);
+
Note this is only available in MySQL and requires direct manipulation of the
-database to add the full-text index.
+database to add the full-text index. By default Django uses BOOLEAN MODE for
+full text searches. `Please check MySQL documentation for additional details. <http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html>`_
+
regex
~~~~~
diff --git a/docs/ref/models/relations.txt b/docs/ref/models/relations.txt
index d0906942e8..9aec52c2b5 100644
--- a/docs/ref/models/relations.txt
+++ b/docs/ref/models/relations.txt
@@ -42,7 +42,7 @@ Extra methods on managers when used in a ForeignKey context
.... body_text='Hi',
.... pub_date=datetime.date(2005, 1, 1)
.... )
- >>> e.save()
+ >>> e.save(force_insert=True)
Note that there's no need to specify the keyword argument of the model that
defines the relationship. In the above example, we don't pass the parameter