Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #10981 -- Clarified documentation regarding lazy cross-…

…application relationships. Thanks to Ramiro for the suggestion.

Merge of r10971 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10974 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 383c46dc8d724db1168e786e5199597453c18c5a 1 parent 0a48904
Russell Keith-Magee authored June 10, 2009

Showing 1 changed file with 20 additions and 10 deletions. Show diff stats Hide diff stats

  1. 30  docs/ref/models/fields.txt
30  docs/ref/models/fields.txt
@@ -800,21 +800,22 @@ you can use the name of the model, rather than the model object itself::
800 800
     class Manufacturer(models.Model):
801 801
         # ...
802 802
 
803  
-Note, however, that this only refers to models in the same ``models.py`` file --
804  
-you cannot use a string to reference a model defined in another application or
805  
-imported from elsewhere.
806  
-
807  
-.. versionchanged:: 1.0
808  
-   Refering models in other applications must include the application label.
  803
+.. versionadded:: 1.0
809 804
 
810  
-To refer to models defined in another
811  
-application, you must instead explicitly specify the application label. For
812  
-example, if the ``Manufacturer`` model above is defined in another application
813  
-called ``production``, you'd need to use::
  805
+To refer to models defined in another application, you can explicitly specify
  806
+a model with the full application label. For example, if the ``Manufacturer``
  807
+model above is defined in another application called ``production``, you'd
  808
+need to use::
814 809
 
815 810
     class Car(models.Model):
816 811
         manufacturer = models.ForeignKey('production.Manufacturer')
817 812
 
  813
+This sort of reference can be useful when resolving circular import
  814
+dependencies between two applications.
  815
+
  816
+Database Representation
  817
+~~~~~~~~~~~~~~~~~~~~~~~
  818
+
818 819
 Behind the scenes, Django appends ``"_id"`` to the field name to create its
819 820
 database column name. In the above example, the database table for the ``Car``
820 821
 model will have a ``manufacturer_id`` column. (You can change this explicitly by
@@ -824,6 +825,9 @@ deal with the field names of your model object.
824 825
 
825 826
 .. _foreign-key-arguments:
826 827
 
  828
+Arguments
  829
+~~~~~~~~~
  830
+
827 831
 :class:`ForeignKey` accepts an extra set of arguments -- all optional -- that
828 832
 define the details of how the relation works.
829 833
 
@@ -871,6 +875,9 @@ the model is related. This works exactly the same as it does for
871 875
 :class:`ForeignKey`, including all the options regarding :ref:`recursive
872 876
 <recursive-relationships>` and :ref:`lazy <lazy-relationships>` relationships.
873 877
 
  878
+Database Representation
  879
+~~~~~~~~~~~~~~~~~~~~~~~
  880
+
874 881
 Behind the scenes, Django creates an intermediary join table to represent the
875 882
 many-to-many relationship. By default, this table name is generated using the
876 883
 names of the two tables being joined. Since some databases don't support table
@@ -882,6 +889,9 @@ You can manually provide the name of the join table using the
882 889
 
883 890
 .. _manytomany-arguments:
884 891
 
  892
+Arguments
  893
+~~~~~~~~~
  894
+
885 895
 :class:`ManyToManyField` accepts an extra set of arguments -- all optional --
886 896
 that control how the relationship functions.
887 897
 

0 notes on commit 383c46d

Please sign in to comment.
Something went wrong with that request. Please try again.