~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to docs/topics/db/models.txt

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (1.2.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: james.westby@ubuntu.com-20101012113435-9lnsrh0i3mxozbt0
Tags: upstream-1.2.3
ImportĀ upstreamĀ versionĀ 1.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. _topics-db-models:
2
 
 
3
1
======
4
2
Models
5
3
======
18
16
    * Each attribute of the model represents a database field.
19
17
 
20
18
    * With all of this, Django gives you an automatically-generated
21
 
      database-access API; see :ref:`topics-db-queries`.
 
19
      database-access API; see :doc:`/topics/db/queries`.
22
20
 
23
21
.. seealso::
24
22
 
64
62
 
65
63
    * The ``CREATE TABLE`` SQL in this example is formatted using PostgreSQL
66
64
      syntax, but it's worth noting Django uses SQL tailored to the database
67
 
      backend specified in your :ref:`settings file <topics-settings>`.
 
65
      backend specified in your :doc:`settings file </topics/settings>`.
68
66
 
69
67
Using models
70
68
============
126
124
Django ships with dozens of built-in field types; you can find the complete list
127
125
in the :ref:`model field reference <model-field-types>`. You can easily write
128
126
your own fields if Django's built-in ones don't do the trick; see
129
 
:ref:`howto-custom-model-fields`.
 
127
:doc:`/howto/custom-model-fields`.
130
128
 
131
129
Field options
132
130
-------------
353
351
 
354
352
As with :class:`~django.db.models.ForeignKey`, you can also create
355
353
:ref:`recursive relationships <recursive-relationships>` (an object with a
356
 
many-to-one relationship to itself) and :ref:`relationships to models not yet
 
354
many-to-many relationship to itself) and :ref:`relationships to models not yet
357
355
defined <lazy-relationships>`; see :ref:`the model field reference
358
356
<ref-manytomany>` for details.
359
357
 
612
610
If one of the existing model fields cannot be used to fit your purposes, or if
613
611
you wish to take advantage of some less common database column types, you can
614
612
create your own field class. Full coverage of creating your own fields is
615
 
provided in :ref:`howto-custom-model-fields`.
 
613
provided in :doc:`/howto/custom-model-fields`.
616
614
 
617
615
.. _meta-options:
618
616
 
634
632
:attr:`~Options.verbose_name_plural`). None are required, and adding ``class
635
633
Meta`` to a model is completely optional.
636
634
 
637
 
A complete list of all possible ``Meta`` options can be found in the :ref:`model
638
 
option reference <ref-models-options>`.
 
635
A complete list of all possible ``Meta`` options can be found in the :doc:`model
 
636
option reference </ref/models/options>`.
639
637
 
640
638
.. _model-methods:
641
639
 
684
682
 
685
683
.. _Read more about properties: http://www.python.org/download/releases/2.2/descrintro/#property
686
684
 
687
 
The :ref:`model instance reference <ref-models-instances>` has a complete list
 
685
The :doc:`model instance reference </ref/models/instances>` has a complete list
688
686
of :ref:`methods automatically given to each model <model-instance-methods>`.
689
687
You can override most of these -- see `overriding predefined model methods`_,
690
688
below -- but there are a couple that you'll almost always want to define:
763
761
 
764
762
Another common pattern is writing custom SQL statements in model methods and
765
763
module-level methods. For more details on using raw SQL, see the documentation
766
 
on :ref:`using raw SQL<topics-db-sql>`.
 
764
on :doc:`using raw SQL</topics/db/sql>`.
767
765
 
768
766
.. _model-inheritance:
769
767