Changeset 8325
- Timestamp:
- 08/12/08 09:15:38 (4 months ago)
- Files:
-
- django/trunk/tests/modeltests/custom_columns/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/files/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/fixtures/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/generic_relations/models.py (modified) (3 diffs)
- django/trunk/tests/modeltests/get_latest/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/get_object_or_404/models.py (modified) (3 diffs)
- django/trunk/tests/modeltests/get_or_create/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/m2m_intermediary/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/m2m_multiple/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/m2m_recursive/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/manipulators/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/many_to_many/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/many_to_one/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/model_forms/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/ordering/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/or_lookups/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/serializers/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/test_client/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/user_commands/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/modeltests/custom_columns/models.py
r7477 r8325 12 12 If you need to use a table name for a many-to-many relationship that differs 13 13 from the default generated name, use the ``db_table`` parameter on the 14 ManyToManyfield. This has no effect on the API for querying the database.14 ``ManyToMany`` field. This has no effect on the API for querying the database. 15 15 16 16 """ … … 88 88 AttributeError: 'Author' object has no attribute 'last' 89 89 90 # Although the Article table uses a custom m2m table, 90 # Although the Article table uses a custom m2m table, 91 91 # nothing about using the m2m relationship has changed... 92 92 django/trunk/tests/modeltests/files/models.py
r8244 r8325 2 2 42. Storing files according to a custom storage system 3 3 4 FileField and its variations can take a "storage" argument to specify how and 5 where files should be stored.4 ``FileField`` and its variations can take a ``storage`` argument to specify how 5 and where files should be stored. 6 6 """ 7 7 django/trunk/tests/modeltests/fixtures/models.py
r7949 r8325 6 6 are identified by name, and are stored in either a directory named 'fixtures' 7 7 in the application directory, on in one of the directories named in the 8 FIXTURE_DIRSsetting.8 ``FIXTURE_DIRS`` setting. 9 9 """ 10 10 django/trunk/tests/modeltests/generic_relations/models.py
r8279 r8325 3 3 4 4 Generic relations let an object have a foreign key to any object through a 5 content-type/object-id field. A generic foreign key can point to any object,6 be it animal, vegetable, or mineral.5 content-type/object-id field. A ``GenericForeignKey`` field can point to any 6 object, be it animal, vegetable, or mineral. 7 7 8 8 The canonical example is tags (although this example implementation is *far* … … 33 33 """ 34 34 comparative = models.CharField(max_length=50) 35 35 36 36 content_type1 = models.ForeignKey(ContentType, related_name="comparative1_set") 37 37 object_id1 = models.PositiveIntegerField() … … 51 51 52 52 tags = generic.GenericRelation(TaggedItem) 53 comparisons = generic.GenericRelation(Comparison, 53 comparisons = generic.GenericRelation(Comparison, 54 54 object_id_field="object_id1", 55 55 content_type_field="content_type1") django/trunk/tests/modeltests/get_latest/models.py
r5876 r8325 3 3 4 4 Models can have a ``get_latest_by`` attribute, which should be set to the name 5 of a DateField or DateTimeField. If ``get_latest_by`` exists, the model's6 m anager will get a ``latest()`` method, which will return the latest object in7 the database according to that field. "Latest" means "having the date farthest 8 into the future."5 of a ``DateField`` or ``DateTimeField``. If ``get_latest_by`` exists, the 6 model's manager will get a ``latest()`` method, which will return the latest 7 object in the database according to that field. "Latest" means "having the date 8 farthest into the future." 9 9 """ 10 10 django/trunk/tests/modeltests/get_object_or_404/models.py
r6838 r8325 2 2 35. DB-API Shortcuts 3 3 4 get_object_or_404is a shortcut function to be used in view functions for5 performing a get() lookup and raising a Http404 exception if a DoesNotExist6 exception was raised during the get()call.4 ``get_object_or_404()`` is a shortcut function to be used in view functions for 5 performing a ``get()`` lookup and raising a ``Http404`` exception if a 6 ``DoesNotExist`` exception was raised during the ``get()`` call. 7 7 8 get_list_or_404is a shortcut function to be used in view functions for9 performing a filter() lookup and raising a Http404 exception if a DoesNotExist10 exception was raised during the filter()call.8 ``get_list_or_404()`` is a shortcut function to be used in view functions for 9 performing a ``filter()`` lookup and raising a ``Http404`` exception if a 10 ``DoesNotExist`` exception was raised during the ``filter()`` call. 11 11 """ 12 12 … … 17 17 class Author(models.Model): 18 18 name = models.CharField(max_length=50) 19 19 20 20 def __unicode__(self): 21 21 return self.name … … 30 30 objects = models.Manager() 31 31 by_a_sir = ArticleManager() 32 32 33 33 def __unicode__(self): 34 34 return self.title django/trunk/tests/modeltests/get_or_create/models.py
r5876 r8325 2 2 33. get_or_create() 3 3 4 get_or_create() does what it says: it tries to look up an object with the given 5 parameters. If an object isn't found, it creates one with the given parameters. 4 ``get_or_create()`` does what it says: it tries to look up an object with the 5 given parameters. If an object isn't found, it creates one with the given 6 parameters. 6 7 """ 7 8 django/trunk/tests/modeltests/m2m_intermediary/models.py
r5876 r8325 5 5 table, use an intermediary model. 6 6 7 In this example, an ``Article`` can have multiple ``Reporter`` s, and each8 ``Article``-``Reporter`` combination (a ``Writer``) has a ``position`` field, 9 which specifies the ``Reporter``'s position for the given article (e.g. "Staff 10 writer").7 In this example, an ``Article`` can have multiple ``Reporter`` objects, and 8 each ``Article``-``Reporter`` combination (a ``Writer``) has a ``position`` 9 field, which specifies the ``Reporter``'s position for the given article 10 (e.g. "Staff writer"). 11 11 """ 12 12 django/trunk/tests/modeltests/m2m_multiple/models.py
r5876 r8325 2 2 20. Multiple many-to-many relationships between the same two tables 3 3 4 In this example, an Article can have many Categories (as "primary") and many5 Categories (as "secondary").4 In this example, an ``Article`` can have many "primary" ``Category`` objects 5 and many "secondary" ``Category`` objects. 6 6 7 7 Set ``related_name`` to designate what the reverse relationship is called. django/trunk/tests/modeltests/m2m_recursive/models.py
r5876 r8325 2 2 28. Many-to-many relationships between the same two tables 3 3 4 In this example, A Person can have many friends, who are also people. Friendship is a 5 symmetrical relationship - if I am your friend, you are my friend. 4 In this example, a ``Person`` can have many friends, who are also ``Person`` 5 objects. Friendship is a symmetrical relationship - if I am your friend, you 6 are my friend. Here, ``friends`` is an example of a symmetrical 7 ``ManyToManyField``. 6 8 7 A person can also have many idols - but while I may idolize you, you may not think 8 the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive 9 m2m fields may be non-symmetrical, and they are symmetrical by default. 9 A ``Person`` can also have many idols - but while I may idolize you, you may 10 not think the same of me. Here, ``idols`` is an example of a non-symmetrical 11 ``ManyToManyField``. Only recursive ``ManyToManyField`` fields may be 12 non-symmetrical, and they are symmetrical by default. 10 13 11 This test validates that the m2m table will create a mangled name for the m2m table if 12 there will be a clash, and tests that symmetry is preserved where appropriate. 14 This test validates that the many-to-many table is created using a mangled name 15 if there is a name clash, and tests that symmetry is preserved where 16 appropriate. 13 17 """ 14 18 django/trunk/tests/modeltests/manipulators/models.py
r7322 r8325 3 3 27. Default manipulators 4 4 5 Each model gets an AddManipulator and ChangeManipulatorby default.5 Each model gets an ``AddManipulator`` and ``ChangeManipulator`` by default. 6 6 """ 7 7 django/trunk/tests/modeltests/many_to_many/models.py
r7622 r8325 2 2 5. Many-to-many relationships 3 3 4 To define a many-to-many relationship, use ManyToManyField().5 6 In this example, an article can be published in multiple publications,7 and a publication has multiple articles.4 To define a many-to-many relationship, use ``ManyToManyField()``. 5 6 In this example, an ``Article`` can be published in multiple ``Publication`` 7 objects, and a ``Publication`` has multiple ``Article`` objects. 8 8 """ 9 9 django/trunk/tests/modeltests/many_to_one/models.py
r8185 r8325 2 2 4. Many-to-one relationships 3 3 4 To define a many-to-one relationship, use ``ForeignKey()`` .4 To define a many-to-one relationship, use ``ForeignKey()``. 5 5 """ 6 6 django/trunk/tests/modeltests/model_forms/models.py
r8291 r8325 2 2 XX. Generating HTML forms from models 3 3 4 This is mostly just a reworking of the form_for_model/form_for_instance tests5 t o use ModelForm. As such, the text may not make sense in all cases, and the6 examples are probably a poor fit for the ModelForm syntax. In other words, 7 most of these tests should be rewritten.4 This is mostly just a reworking of the ``form_for_model``/``form_for_instance`` 5 tests to use ``ModelForm``. As such, the text may not make sense in all cases, 6 and the examples are probably a poor fit for the ``ModelForm`` syntax. In other 7 words, most of these tests should be rewritten. 8 8 """ 9 9 django/trunk/tests/modeltests/ordering/models.py
r7477 r8325 4 4 Specify default ordering for a model using the ``ordering`` attribute, which 5 5 should be a list or tuple of field names. This tells Django how to order 6 querysetresults.6 ``QuerySet`` results. 7 7 8 8 If a field name in ``ordering`` starts with a hyphen, that field will be django/trunk/tests/modeltests/or_lookups/models.py
r7914 r8325 2 2 19. OR lookups 3 3 4 To perform an OR lookup, or a lookup that combines ANDs and ORs, 5 combine QuerySet objects using & and |operators.4 To perform an OR lookup, or a lookup that combines ANDs and ORs, combine 5 ``QuerySet`` objects using ``&`` and ``|`` operators. 6 6 7 7 Alternatively, use positional arguments, and pass one or more expressions of 8 8 clauses using the variable ``django.db.models.Q`` (or any object with an 9 add_to_querymethod).9 ``add_to_query`` method). 10 10 """ 11 11 # Python 2.3 doesn't have sorted() django/trunk/tests/modeltests/serializers/models.py
r7477 r8325 3 3 42. Serialization 4 4 5 ``django.core.serializers`` provides interfaces to converting Django querysets6 to and from "flat" data (i.e. strings).5 ``django.core.serializers`` provides interfaces to converting Django 6 ``QuerySet`` objects to and from "flat" data (i.e. strings). 7 7 """ 8 8 django/trunk/tests/modeltests/test_client/models.py
r7900 r8325 12 12 process of serving the request. 13 13 14 Clientobjects are stateful - they will retain cookie (and15 thus session) details for the lifetime of the Clientinstance.16 17 This is not intended as a replacement for Twill, Selenium, or14 ``Client`` objects are stateful - they will retain cookie (and 15 thus session) details for the lifetime of the ``Client`` instance. 16 17 This is not intended as a replacement for Twill, Selenium, or 18 18 other browser automation frameworks - it is here to allow 19 19 testing against the contexts and templates produced by a view, django/trunk/tests/modeltests/user_commands/models.py
r7294 r8325 2 2 38. User-registered management commands 3 3 4 The manage.pyutility provides a number of useful commands for managing a4 The ``manage.py`` utility provides a number of useful commands for managing a 5 5 Django project. If you want to add a utility command of your own, you can. 6 6 7 The user-defined command 'dance' is defined in the management/commands8 subdirectory of this test application. It is a simple command that responds 7 The user-defined command ``dance`` is defined in the management/commands 8 subdirectory of this test application. It is a simple command that responds 9 9 with a printed message when invoked. 10 10 11 For more details on how to define your own manage.pycommands, look at the12 django.core.management.commandsdirectory. This directory contains the13 definitions for the base Django manage.pycommands.11 For more details on how to define your own ``manage.py`` commands, look at the 12 ``django.core.management.commands`` directory. This directory contains the 13 definitions for the base Django ``manage.py`` commands. 14 14 """ 15 15
