Fixed a few class references in the model field docs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10207 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
08056572e8
commit
ef933f1643
|
@ -45,11 +45,11 @@ booleans and dates. For both types of fields, you will also need to set
|
||||||
:attr:`~Field.blank`).
|
:attr:`~Field.blank`).
|
||||||
|
|
||||||
Avoid using :attr:`~Field.null` on string-based fields such as
|
Avoid using :attr:`~Field.null` on string-based fields such as
|
||||||
:class:`CharField` and :class:`TextField` unless you have an excellent reason.
|
:class:`~django.db.models.CharField` and :class:`~django.db.models.TextField`
|
||||||
If a string-based field has ``null=True``, that means it has two possible values
|
unless you have an excellent reason. If a string-based field has ``null=True``,
|
||||||
for "no data": ``NULL``, and the empty string. In most cases, it's redundant to
|
that means it has two possible values for "no data": ``NULL``, and the empty
|
||||||
have two possible values for "no data;" Django convention is to use the empty
|
string. In most cases, it's redundant to have two possible values for "no
|
||||||
string, not ``NULL``.
|
data;" Django convention is to use the empty string, not ``NULL``.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
@ -142,8 +142,9 @@ documentation.
|
||||||
Finally, note that choices can be any iterable object -- not necessarily a list
|
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
|
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
|
hacking :attr:`~Field.choices` to be dynamic, you're probably better off using a
|
||||||
proper database table with a :class:`ForeignKey`. :attr:`~Field.choices` is
|
proper database table with a :class:`~django.db.models.ForeignKey`.
|
||||||
meant for static data that doesn't change much, if ever.
|
:attr:`~Field.choices` is meant for static data that doesn't change much, if
|
||||||
|
ever.
|
||||||
|
|
||||||
``db_column``
|
``db_column``
|
||||||
-------------
|
-------------
|
||||||
|
@ -219,10 +220,10 @@ Alternatively you can use plain text and
|
||||||
If ``True``, this field is the primary key for the model.
|
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
|
If you don't specify ``primary_key=True`` for any fields in your model, Django
|
||||||
will automatically add an :class:`IntegerField` to hold the primary key, so you
|
will automatically add an :class:`~django.db.models.IntegerField` to hold the
|
||||||
don't need to set ``primary_key=True`` on any of your fields unless you want to
|
primary key, so you don't need to set ``primary_key=True`` on any of your
|
||||||
override the default primary-key behavior. For more, see
|
fields unless you want to override the default primary-key behavior. For more,
|
||||||
:ref:`automatic-primary-key-fields`.
|
see :ref:`automatic-primary-key-fields`.
|
||||||
|
|
||||||
``primary_key=True`` implies :attr:`null=False <Field.null>` and :attr:`unique=True <Field.unique>`.
|
``primary_key=True`` implies :attr:`null=False <Field.null>` and :attr:`unique=True <Field.unique>`.
|
||||||
Only one primary key is allowed on an object.
|
Only one primary key is allowed on an object.
|
||||||
|
@ -239,16 +240,18 @@ 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
|
field, a :exc:`django.db.IntegrityError` will be raised by the model's
|
||||||
:meth:`~django.db.models.Model.save` method.
|
:meth:`~django.db.models.Model.save` method.
|
||||||
|
|
||||||
This option is valid on all field types except :class:`ManyToManyField` and
|
This option is valid on all field types except
|
||||||
:class:`FileField`.
|
:class:`~django.db.models.ManyToManyField` and
|
||||||
|
:class:`~django.db.models.FileField`.
|
||||||
|
|
||||||
``unique_for_date``
|
``unique_for_date``
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
.. attribute:: Field.unique_for_date
|
.. attribute:: Field.unique_for_date
|
||||||
|
|
||||||
Set this to the name of a :class:`DateField` or :class:`DateTimeField` to
|
Set this to the name of a :class:`~django.db.models.DateField` or
|
||||||
require that this field be unique for the value of the date field.
|
:class:`~django.db.models.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
|
For example, if you have a field ``title`` that has
|
||||||
``unique_for_date="pub_date"``, then Django wouldn't allow the entry of two
|
``unique_for_date="pub_date"``, then Django wouldn't allow the entry of two
|
||||||
|
|
Loading…
Reference in New Issue