Kaydet (Commit) 2f3a4cd5 authored tarafından Loic Bistuer's avatar Loic Bistuer

Removed numbering from the models.py header of some test packages.

This is a reliqua from the early days of the modeltests/regressiontests era.
üst d128eac3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
1. Bare-bones model Bare-bones model
This is a basic model with only two non-primary-key fields. This is a basic model with only two non-primary-key fields.
""" """
......
""" """
21. Specifying 'choices' for a field Specifying 'choices' for a field
Most fields take a ``choices`` parameter, which should be a tuple of tuples Most fields take a ``choices`` parameter, which should be a tuple of tuples
specifying which are the valid values for that field. specifying which are the valid values for that field.
......
""" """
17. Custom column/table names Custom column/table names
If your database column name is different than your model attribute, use the If your database column name is different than your model attribute, use the
``db_column`` parameter. Note that you'll use the field's name, not its column ``db_column`` parameter. Note that you'll use the field's name, not its column
......
""" """
23. Giving models a custom manager Giving models a custom manager
You can use a custom ``Manager`` in a particular model by extending the base You can use a custom ``Manager`` in a particular model by extending the base
``Manager`` class and instantiating your custom ``Manager`` in your model. ``Manager`` class and instantiating your custom ``Manager`` in your model.
......
""" """
3. Giving models custom methods Giving models custom methods
Any method you add to a model will be available to instances. Any method you add to a model will be available to instances.
""" """
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
14. Using a custom primary key Using a custom primary key
By default, Django adds an ``"id"`` field to each model. But you can override By default, Django adds an ``"id"`` field to each model. But you can override
this behavior by explicitly adding ``primary_key=True`` to a field. this behavior by explicitly adding ``primary_key=True`` to a field.
......
""" """
40. Empty model tests Empty model tests
These test that things behave sensibly for the rare corner-case of a model with These test that things behave sensibly for the rare corner-case of a model with
no fields. no fields.
......
# coding: utf-8 # coding: utf-8
""" """
32. Callable defaults Callable defaults
You can pass callable objects as the ``default`` parameter to a field. When You can pass callable objects as the ``default`` parameter to a field. When
the object is created without an explicit value passed in, Django will call the object is created without an explicit value passed in, Django will call
......
""" """
42. Storing files according to a custom storage system Storing files according to a custom storage system
``FileField`` and its variations can take a ``storage`` argument to specify how ``FileField`` and its variations can take a ``storage`` argument to specify how
and where files should be stored. and where files should be stored.
......
""" """
37. Fixtures. Fixtures.
Fixtures are a way of loading data into the database in bulk. Fixure data 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 can be stored in any serializable format (including JSON and XML). Fixtures
......
""" """
34. Generic relations Generic relations
Generic relations let an object have a foreign key to any object through a Generic relations let an object have a foreign key to any object through a
content-type/object-id field. A ``GenericForeignKey`` field can point to any content-type/object-id field. A ``GenericForeignKey`` field can point to any
......
""" """
35. DB-API Shortcuts DB-API Shortcuts
``get_object_or_404()`` is a shortcut function to be used in view functions for ``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 performing a ``get()`` lookup and raising a ``Http404`` exception if a
......
""" """
7. The lookup API The lookup API
This demonstrates features of the database API. This demonstrates features of the database API.
""" """
......
""" """
29. Many-to-many and many-to-one relationships to the same table Many-to-many and many-to-one relationships to the same table
Make sure to set ``related_name`` if you use relationships to the same table. Make sure to set ``related_name`` if you use relationships to the same table.
""" """
......
""" """
9. Many-to-many relationships via an intermediary table Many-to-many relationships via an intermediary table
For many-to-many relationships that need extra fields on the intermediary For many-to-many relationships that need extra fields on the intermediary
table, use an intermediary model. table, use an intermediary model.
......
""" """
20. Multiple many-to-many relationships between the same two tables Multiple many-to-many relationships between the same two tables
In this example, an ``Article`` can have many "primary" ``Category`` objects In this example, an ``Article`` can have many "primary" ``Category`` objects
and many "secondary" ``Category`` objects. and many "secondary" ``Category`` objects.
......
""" """
28. Many-to-many relationships between the same two tables Many-to-many relationships between the same two tables
In this example, a ``Person`` can have many friends, who are also ``Person`` 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 objects. Friendship is a symmetrical relationship - if I am your friend, you
......
""" """
11. Relating an object to itself, many-to-one Relating an object to itself, many-to-one
To define a many-to-one relationship between a model and itself, use To define a many-to-one relationship between a model and itself, use
``ForeignKey('self')``. ``ForeignKey('self')``.
......
""" """
5. Many-to-many relationships Many-to-many relationships
To define a many-to-many relationship, use ``ManyToManyField()``. To define a many-to-many relationship, use ``ManyToManyField()``.
......
""" """
4. Many-to-one relationships Many-to-one relationships
To define a many-to-one relationship, use ``ForeignKey()``. To define a many-to-one relationship, use ``ForeignKey()``.
""" """
......
""" """
16. Many-to-one relationships that can be null Many-to-one relationships that can be null
To define a many-to-one relationship that can have a null foreign key, use To define a many-to-one relationship that can have a null foreign key, use
``ForeignKey()`` with ``null=True`` . ``ForeignKey()`` with ``null=True`` .
......
""" """
24. Mutually referential many-to-one relationships Mutually referential many-to-one relationships
Strings can be used instead of model literals to set up "lazy" relations. Strings can be used instead of model literals to set up "lazy" relations.
""" """
......
""" """
10. One-to-one relationships One-to-one relationships
To define a one-to-one relationship, use ``OneToOneField()``. To define a one-to-one relationship, use ``OneToOneField()``.
......
""" """
19. OR lookups OR lookups
To perform an OR lookup, or a lookup that combines ANDs and ORs, combine To perform an OR lookup, or a lookup that combines ANDs and ORs, combine
``QuerySet`` objects using ``&`` and ``|`` operators. ``QuerySet`` objects using ``&`` and ``|`` operators.
......
""" """
6. Specifying ordering Specifying ordering
Specify default ordering for a model using the ``ordering`` attribute, which 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 should be a list or tuple of field names. This tells Django how to order
......
""" """
22. Using properties on models Using properties on models
Use properties on models just like on any other Python object. Use properties on models just like on any other Python object.
""" """
......
""" """
18. Using SQL reserved names Using SQL reserved names
Need to use a reserved SQL name as a column name or table name? Need to include Need to use a reserved SQL name as a column name or table name? Need to include
a hyphen in a column or table name? No problem. Django quotes names a hyphen in a column or table name? No problem. Django quotes names
......
""" """
25. Reverse lookups Reverse lookups
This demonstrates the reverse lookup features of the database API. This demonstrates the reverse lookup features of the database API.
""" """
......
""" """
13. Adding hooks before/after saving and deleting Adding hooks before/after saving and deleting
To execute arbitrary code around ``save()`` and ``delete()``, just subclass To execute arbitrary code around ``save()`` and ``delete()``, just subclass
the methods. the methods.
......
""" """
41. Tests for select_related() Tests for select_related()
``select_related()`` follows all relationships and pre-caches any foreign key ``select_related()`` follows all relationships and pre-caches any foreign key
values so that complex trees can be fetched in a single query. However, this values so that complex trees can be fetched in a single query. However, this
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
42. Serialization Serialization
``django.core.serializers`` provides interfaces to converting Django ``django.core.serializers`` provides interfaces to converting Django
``QuerySet`` objects to and from "flat" data (i.e. strings). ``QuerySet`` objects to and from "flat" data (i.e. strings).
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
2. Adding __str__() or __unicode__() to models Adding __str__() or __unicode__() to models
Although it's not a strict requirement, each model should have a Although it's not a strict requirement, each model should have a
``_str__()`` or ``__unicode__()`` method to return a "human-readable" ``_str__()`` or ``__unicode__()`` method to return a "human-readable"
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
39. Testing using the Test Client Testing using the Test Client
The test client is a class that can act like a simple The test client is a class that can act like a simple
browser for testing purposes. browser for testing purposes.
......
""" """
15. Transactions Transactions
Django handles transactions in three different ways. The default is to commit Django handles transactions in three different ways. The default is to commit
each transaction upon a write, but you can decorate a function to get each transaction upon a write, but you can decorate a function to get
......
""" """
38. User-registered management commands 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. Django project. If you want to add a utility command of your own, you can.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment