Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gdub committed Aug 12, 2008
1 parent c4d07d4 commit 1697f4e
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 62 deletions.
4 changes: 2 additions & 2 deletions tests/modeltests/custom_columns/models.py
Expand Up @@ -11,7 +11,7 @@
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.
"""

Expand Down Expand Up @@ -87,7 +87,7 @@ class Meta:
...
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
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down
2 changes: 1 addition & 1 deletion tests/modeltests/fixtures/models.py
Expand Up @@ -5,7 +5,7 @@
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
Expand Down
8 changes: 4 additions & 4 deletions tests/modeltests/generic_relations/models.py
Expand Up @@ -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).
Expand Down Expand Up @@ -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()

Expand All @@ -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")

Expand Down
8 changes: 4 additions & 4 deletions tests/modeltests/get_latest/models.py
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions 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
Expand All @@ -16,7 +16,7 @@

class Author(models.Model):
name = models.CharField(max_length=50)

def __unicode__(self):
return self.name

Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions 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
Expand Down
8 changes: 4 additions & 4 deletions tests/modeltests/m2m_intermediary/models.py
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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.
"""
Expand Down
22 changes: 13 additions & 9 deletions 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.
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.
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.
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. 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 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
Expand Down
2 changes: 1 addition & 1 deletion tests/modeltests/manipulators/models.py
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions 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
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
8 changes: 4 additions & 4 deletions 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
Expand Down
6 changes: 3 additions & 3 deletions 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:
Expand Down
2 changes: 1 addition & 1 deletion tests/modeltests/ordering/models.py
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions tests/modeltests/serializers/models.py
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/modeltests/test_client/models.py
Expand Up @@ -11,10 +11,10 @@
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.
Expand Down
12 changes: 6 additions & 6 deletions 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': """
Expand Down

0 comments on commit 1697f4e

Please sign in to comment.