From 1697f4e49f782f6d793911ba7d24da6e0dac485e Mon Sep 17 00:00:00 2001 From: Gary Wilson Jr Date: Tue, 12 Aug 2008 14:15:38 +0000 Subject: [PATCH] Fixed a couple typos in the modeltests' descriptions and made use of ReST inline literal markup for code snippets. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8325 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/custom_columns/models.py | 4 ++-- tests/modeltests/files/models.py | 4 ++-- tests/modeltests/fixtures/models.py | 2 +- tests/modeltests/generic_relations/models.py | 8 ++++---- tests/modeltests/get_latest/models.py | 8 ++++---- tests/modeltests/get_object_or_404/models.py | 16 ++++++++-------- tests/modeltests/get_or_create/models.py | 5 +++-- tests/modeltests/m2m_intermediary/models.py | 8 ++++---- tests/modeltests/m2m_multiple/models.py | 4 ++-- tests/modeltests/m2m_recursive/models.py | 18 +++++++++++------- tests/modeltests/manipulators/models.py | 2 +- tests/modeltests/many_to_many/models.py | 6 +++--- tests/modeltests/many_to_one/models.py | 2 +- tests/modeltests/model_forms/models.py | 8 ++++---- tests/modeltests/or_lookups/models.py | 6 +++--- tests/modeltests/ordering/models.py | 2 +- tests/modeltests/serializers/models.py | 4 ++-- tests/modeltests/test_client/models.py | 6 +++--- tests/modeltests/user_commands/models.py | 12 ++++++------ 19 files changed, 65 insertions(+), 60 deletions(-) diff --git a/tests/modeltests/custom_columns/models.py b/tests/modeltests/custom_columns/models.py index a0800299a7..3be31339ce 100644 --- a/tests/modeltests/custom_columns/models.py +++ b/tests/modeltests/custom_columns/models.py @@ -11,7 +11,7 @@ query the database. If you need to use a table name for a many-to-many relationship that differs from the default generated name, use the ``db_table`` parameter on the -ManyToMany field. This has no effect on the API for querying the database. +``ManyToMany`` field. This has no effect on the API for querying the database. """ @@ -87,7 +87,7 @@ Traceback (most recent call last): ... AttributeError: 'Author' object has no attribute 'last' -# Although the Article table uses a custom m2m table, +# Although the Article table uses a custom m2m table, # nothing about using the m2m relationship has changed... # Get all the authors for an article diff --git a/tests/modeltests/files/models.py b/tests/modeltests/files/models.py index a2ee5a7256..c9cfc357c3 100644 --- a/tests/modeltests/files/models.py +++ b/tests/modeltests/files/models.py @@ -1,8 +1,8 @@ """ 42. Storing files according to a custom storage system -FileField and its variations can take a "storage" argument to specify how and -where files should be stored. +``FileField`` and its variations can take a ``storage`` argument to specify how +and where files should be stored. """ import tempfile diff --git a/tests/modeltests/fixtures/models.py b/tests/modeltests/fixtures/models.py index 8f8893ac88..e9b7242c9c 100644 --- a/tests/modeltests/fixtures/models.py +++ b/tests/modeltests/fixtures/models.py @@ -5,7 +5,7 @@ Fixtures are a way of loading data into the database in bulk. Fixure data can be stored in any serializable format (including JSON and XML). Fixtures are identified by name, and are stored in either a directory named 'fixtures' in the application directory, on in one of the directories named in the -FIXTURE_DIRS setting. +``FIXTURE_DIRS`` setting. """ from django.db import models diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py index 401b616efc..cbfb37dbad 100644 --- a/tests/modeltests/generic_relations/models.py +++ b/tests/modeltests/generic_relations/models.py @@ -2,8 +2,8 @@ 34. Generic relations Generic relations let an object have a foreign key to any object through a -content-type/object-id field. A generic foreign key can point to any object, -be it animal, vegetable, or mineral. +content-type/object-id field. A ``GenericForeignKey`` field can point to any +object, be it animal, vegetable, or mineral. The canonical example is tags (although this example implementation is *far* from complete). @@ -32,7 +32,7 @@ class Comparison(models.Model): A model that tests having multiple GenericForeignKeys """ comparative = models.CharField(max_length=50) - + content_type1 = models.ForeignKey(ContentType, related_name="comparative1_set") object_id1 = models.PositiveIntegerField() @@ -50,7 +50,7 @@ class Animal(models.Model): latin_name = models.CharField(max_length=150) tags = generic.GenericRelation(TaggedItem) - comparisons = generic.GenericRelation(Comparison, + comparisons = generic.GenericRelation(Comparison, object_id_field="object_id1", content_type_field="content_type1") diff --git a/tests/modeltests/get_latest/models.py b/tests/modeltests/get_latest/models.py index 099f1e28a6..624f3a879a 100644 --- a/tests/modeltests/get_latest/models.py +++ b/tests/modeltests/get_latest/models.py @@ -2,10 +2,10 @@ 8. get_latest_by Models can have a ``get_latest_by`` attribute, which should be set to the name -of a DateField or DateTimeField. If ``get_latest_by`` exists, the model's -manager will get a ``latest()`` method, which will return the latest object in -the database according to that field. "Latest" means "having the date farthest -into the future." +of a ``DateField`` or ``DateTimeField``. If ``get_latest_by`` exists, the +model's manager will get a ``latest()`` method, which will return the latest +object in the database according to that field. "Latest" means "having the date +farthest into the future." """ from django.db import models diff --git a/tests/modeltests/get_object_or_404/models.py b/tests/modeltests/get_object_or_404/models.py index d9f276b024..6e4da44481 100644 --- a/tests/modeltests/get_object_or_404/models.py +++ b/tests/modeltests/get_object_or_404/models.py @@ -1,13 +1,13 @@ """ 35. DB-API Shortcuts -get_object_or_404 is a shortcut function to be used in view functions for -performing a get() lookup and raising a Http404 exception if a DoesNotExist -exception was raised during the get() call. +``get_object_or_404()`` is a shortcut function to be used in view functions for +performing a ``get()`` lookup and raising a ``Http404`` exception if a +``DoesNotExist`` exception was raised during the ``get()`` call. -get_list_or_404 is a shortcut function to be used in view functions for -performing a filter() lookup and raising a Http404 exception if a DoesNotExist -exception was raised during the filter() call. +``get_list_or_404()`` is a shortcut function to be used in view functions for +performing a ``filter()`` lookup and raising a ``Http404`` exception if a +``DoesNotExist`` exception was raised during the ``filter()`` call. """ from django.db import models @@ -16,7 +16,7 @@ from django.shortcuts import get_object_or_404, get_list_or_404 class Author(models.Model): name = models.CharField(max_length=50) - + def __unicode__(self): return self.name @@ -29,7 +29,7 @@ class Article(models.Model): title = models.CharField(max_length=50) objects = models.Manager() by_a_sir = ArticleManager() - + def __unicode__(self): return self.title diff --git a/tests/modeltests/get_or_create/models.py b/tests/modeltests/get_or_create/models.py index 9f025dc582..3a1b447c97 100644 --- a/tests/modeltests/get_or_create/models.py +++ b/tests/modeltests/get_or_create/models.py @@ -1,8 +1,9 @@ """ 33. get_or_create() -get_or_create() does what it says: it tries to look up an object with the given -parameters. If an object isn't found, it creates one with the given parameters. +``get_or_create()`` does what it says: it tries to look up an object with the +given parameters. If an object isn't found, it creates one with the given +parameters. """ from django.db import models diff --git a/tests/modeltests/m2m_intermediary/models.py b/tests/modeltests/m2m_intermediary/models.py index 0f93d5a154..e9f964aa4e 100644 --- a/tests/modeltests/m2m_intermediary/models.py +++ b/tests/modeltests/m2m_intermediary/models.py @@ -4,10 +4,10 @@ For many-to-many relationships that need extra fields on the intermediary table, use an intermediary model. -In this example, an ``Article`` can have multiple ``Reporter``s, and each -``Article``-``Reporter`` combination (a ``Writer``) has a ``position`` field, -which specifies the ``Reporter``'s position for the given article (e.g. "Staff -writer"). +In this example, an ``Article`` can have multiple ``Reporter`` objects, and +each ``Article``-``Reporter`` combination (a ``Writer``) has a ``position`` +field, which specifies the ``Reporter``'s position for the given article +(e.g. "Staff writer"). """ from django.db import models diff --git a/tests/modeltests/m2m_multiple/models.py b/tests/modeltests/m2m_multiple/models.py index 26a0a2e798..42e74553d9 100644 --- a/tests/modeltests/m2m_multiple/models.py +++ b/tests/modeltests/m2m_multiple/models.py @@ -1,8 +1,8 @@ """ 20. Multiple many-to-many relationships between the same two tables -In this example, an Article can have many Categories (as "primary") and many -Categories (as "secondary"). +In this example, an ``Article`` can have many "primary" ``Category`` objects +and many "secondary" ``Category`` objects. Set ``related_name`` to designate what the reverse relationship is called. """ diff --git a/tests/modeltests/m2m_recursive/models.py b/tests/modeltests/m2m_recursive/models.py index 98f5ce526a..23be6f31ba 100644 --- a/tests/modeltests/m2m_recursive/models.py +++ b/tests/modeltests/m2m_recursive/models.py @@ -1,15 +1,19 @@ """ 28. Many-to-many relationships between the same two tables -In this example, A Person can have many friends, who are also people. Friendship is a -symmetrical relationship - if I am your friend, you are my friend. +In this example, a ``Person`` can have many friends, who are also ``Person`` +objects. Friendship is a symmetrical relationship - if I am your friend, you +are my friend. Here, ``friends`` is an example of a symmetrical +``ManyToManyField``. -A person can also have many idols - but while I may idolize you, you may not think -the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive -m2m fields may be non-symmetrical, and they are symmetrical by default. +A ``Person`` can also have many idols - but while I may idolize you, you may +not think the same of me. Here, ``idols`` is an example of a non-symmetrical +``ManyToManyField``. Only recursive ``ManyToManyField`` fields may be +non-symmetrical, and they are symmetrical by default. -This test validates that the m2m table will create a mangled name for the m2m table if -there will be a clash, and tests that symmetry is preserved where appropriate. +This test validates that the many-to-many table is created using a mangled name +if there is a name clash, and tests that symmetry is preserved where +appropriate. """ from django.db import models diff --git a/tests/modeltests/manipulators/models.py b/tests/modeltests/manipulators/models.py index 3e52e33bbb..0adee9ed39 100644 --- a/tests/modeltests/manipulators/models.py +++ b/tests/modeltests/manipulators/models.py @@ -2,7 +2,7 @@ """ 27. Default manipulators -Each model gets an AddManipulator and ChangeManipulator by default. +Each model gets an ``AddManipulator`` and ``ChangeManipulator`` by default. """ from django.db import models diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py index c2ab2897b6..cc34c868b9 100644 --- a/tests/modeltests/many_to_many/models.py +++ b/tests/modeltests/many_to_many/models.py @@ -1,10 +1,10 @@ """ 5. Many-to-many relationships -To define a many-to-many relationship, use ManyToManyField(). +To define a many-to-many relationship, use ``ManyToManyField()``. -In this example, an article can be published in multiple publications, -and a publication has multiple articles. +In this example, an ``Article`` can be published in multiple ``Publication`` +objects, and a ``Publication`` has multiple ``Article`` objects. """ from django.db import models diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py index 2dd1226e97..1972ac72ee 100644 --- a/tests/modeltests/many_to_one/models.py +++ b/tests/modeltests/many_to_one/models.py @@ -1,7 +1,7 @@ """ 4. Many-to-one relationships -To define a many-to-one relationship, use ``ForeignKey()`` . +To define a many-to-one relationship, use ``ForeignKey()``. """ from django.db import models diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py index 8d919efee3..56154f8a5b 100644 --- a/tests/modeltests/model_forms/models.py +++ b/tests/modeltests/model_forms/models.py @@ -1,10 +1,10 @@ """ XX. Generating HTML forms from models -This is mostly just a reworking of the form_for_model/form_for_instance tests -to use ModelForm. As such, the text may not make sense in all cases, and the -examples are probably a poor fit for the ModelForm syntax. In other words, -most of these tests should be rewritten. +This is mostly just a reworking of the ``form_for_model``/``form_for_instance`` +tests to use ``ModelForm``. As such, the text may not make sense in all cases, +and the examples are probably a poor fit for the ``ModelForm`` syntax. In other +words, most of these tests should be rewritten. """ import os diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py index 6e56095d7c..60b40d021d 100644 --- a/tests/modeltests/or_lookups/models.py +++ b/tests/modeltests/or_lookups/models.py @@ -1,12 +1,12 @@ """ 19. OR lookups -To perform an OR lookup, or a lookup that combines ANDs and ORs, -combine QuerySet objects using & and | operators. +To perform an OR lookup, or a lookup that combines ANDs and ORs, combine +``QuerySet`` objects using ``&`` and ``|`` operators. Alternatively, use positional arguments, and pass one or more expressions of clauses using the variable ``django.db.models.Q`` (or any object with an -add_to_query method). +``add_to_query`` method). """ # Python 2.3 doesn't have sorted() try: diff --git a/tests/modeltests/ordering/models.py b/tests/modeltests/ordering/models.py index d7435f6f74..94d24b352d 100644 --- a/tests/modeltests/ordering/models.py +++ b/tests/modeltests/ordering/models.py @@ -3,7 +3,7 @@ Specify default ordering for a model using the ``ordering`` attribute, which should be a list or tuple of field names. This tells Django how to order -queryset results. +``QuerySet`` results. If a field name in ``ordering`` starts with a hyphen, that field will be ordered in descending order. Otherwise, it'll be ordered in ascending order. diff --git a/tests/modeltests/serializers/models.py b/tests/modeltests/serializers/models.py index f9dd8f288b..f9130d1dfc 100644 --- a/tests/modeltests/serializers/models.py +++ b/tests/modeltests/serializers/models.py @@ -2,8 +2,8 @@ """ 42. Serialization -``django.core.serializers`` provides interfaces to converting Django querysets -to and from "flat" data (i.e. strings). +``django.core.serializers`` provides interfaces to converting Django +``QuerySet`` objects to and from "flat" data (i.e. strings). """ from django.db import models diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py index 3797bf2d52..2cca618b4e 100644 --- a/tests/modeltests/test_client/models.py +++ b/tests/modeltests/test_client/models.py @@ -11,10 +11,10 @@ The server Response objects are annotated with the details of the contexts and templates that were rendered during the process of serving the request. -Client objects are stateful - they will retain cookie (and -thus session) details for the lifetime of the Client instance. +``Client`` objects are stateful - they will retain cookie (and +thus session) details for the lifetime of the ``Client`` instance. -This is not intended as a replacement for Twill,Selenium, or +This is not intended as a replacement for Twill, Selenium, or other browser automation frameworks - it is here to allow testing against the contexts and templates produced by a view, rather than the HTML rendered to the end-user. diff --git a/tests/modeltests/user_commands/models.py b/tests/modeltests/user_commands/models.py index 6db4b049df..8dd7205f98 100644 --- a/tests/modeltests/user_commands/models.py +++ b/tests/modeltests/user_commands/models.py @@ -1,16 +1,16 @@ """ 38. User-registered management commands -The manage.py utility provides a number of useful commands for managing a +The ``manage.py`` utility provides a number of useful commands for managing a Django project. If you want to add a utility command of your own, you can. -The user-defined command 'dance' is defined in the management/commands -subdirectory of this test application. It is a simple command that responds +The user-defined command ``dance`` is defined in the management/commands +subdirectory of this test application. It is a simple command that responds with a printed message when invoked. -For more details on how to define your own manage.py commands, look at the -django.core.management.commands directory. This directory contains the -definitions for the base Django manage.py commands. +For more details on how to define your own ``manage.py`` commands, look at the +``django.core.management.commands`` directory. This directory contains the +definitions for the base Django ``manage.py`` commands. """ __test__ = {'API_TESTS': """