diff options
author | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
---|---|---|
committer | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
commit | dd49269c7db008b2567f50cb03c4d3d9b321daa1 (patch) | |
tree | 326dd25bb045ac016cda7966b43cbdfe1f67d699 /docs/ref/models/instances.txt | |
parent | c9b188c4ec939abbe48dae5a371276742e64b6b8 (diff) | |
download | django-soc2010/app-loading.tar.gz |
[soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loading
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/models/instances.txt')
-rw-r--r-- | docs/ref/models/instances.txt | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 7e6cdeb5c7..dfe4c747e8 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -1,5 +1,3 @@ -.. _ref-models-instances: - ======================== Model instance reference ======================== @@ -7,13 +5,13 @@ Model instance reference .. currentmodule:: django.db.models This document describes the details of the ``Model`` API. It builds on the -material presented in the :ref:`model <topics-db-models>` and :ref:`database -query <topics-db-queries>` guides, so you'll probably want to read and +material presented in the :doc:`model </topics/db/models>` and :doc:`database +query </topics/db/queries>` guides, so you'll probably want to read and understand those documents before reading this one. Throughout this reference we'll use the :ref:`example weblog models -<queryset-model-example>` presented in the :ref:`database query guide -<topics-db-queries>`. +<queryset-model-example>` presented in the :doc:`database query guide +</topics/db/queries>`. Creating objects ================ @@ -45,8 +43,8 @@ All three steps are performed when you call by a model's When you use a ``ModelForm``, the call to ``is_valid()`` will perform these validation steps for all the fields that are included on the -form. (See the :ref:`ModelForm documentation -<topics-forms-modelforms>` for more information.) You should only need +form. (See the :doc:`ModelForm documentation +</topics/forms/modelforms>` for more information.) You should only need to call a model's ``full_clean()`` method if you plan to handle validation errors yourself, or if you have excluded fields from the ModelForm that require validation. @@ -107,9 +105,9 @@ special key that is used for errors that are tied to the entire model instead of to a specific field. You can access these errors with ``NON_FIELD_ERRORS``:: - from django.core.validators import ValidationError, NON_FIELD_ERRORS + from django.core.exceptions import ValidationError, NON_FIELD_ERRORS try: - article.full_clean(): + article.full_clean() except ValidationError, e: non_field_errors = e.message_dict[NON_FIELD_ERRORS] @@ -215,7 +213,7 @@ What happens when you save? When you save an object, Django performs the following steps: - 1. **Emit a pre-save signal.** The :ref:`signal <ref-signals>` + 1. **Emit a pre-save signal.** The :doc:`signal </ref/signals>` :attr:`django.db.models.signals.pre_save` is sent, allowing any functions listening for that signal to take some customized action. @@ -426,8 +424,8 @@ Django uses this in its admin interface. If an object defines link that will jump you directly to the object's public view, according to ``get_absolute_url()``. -Also, a couple of other bits of Django, such as the :ref:`syndication feed -framework <ref-contrib-syndication>`, use ``get_absolute_url()`` as a +Also, a couple of other bits of Django, such as the :doc:`syndication feed +framework </ref/contrib/syndication>`, use ``get_absolute_url()`` as a convenience to reward people who've defined the method. It's good practice to use ``get_absolute_url()`` in templates, instead of @@ -517,14 +515,14 @@ the ``url`` function):: ...and then using that name to perform the reverse URL resolution instead of the view name:: - from django.db.models import permalink + from django.db import models @models.permalink def get_absolute_url(self): return ('people_view', [str(self.id)]) -More details on named URL patterns are in the :ref:`URL dispatch documentation -<topics-http-urls>`. +More details on named URL patterns are in the :doc:`URL dispatch documentation +</topics/http/urls>`. Extra instance methods ====================== @@ -570,3 +568,5 @@ described in :ref:`Field lookups <field-lookups>`. Note that in the case of identical date values, these methods will use the ID as a fallback check. This guarantees that no records are skipped or duplicated. + +That also means you cannot use those methods on unsaved objects. |