summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/admin/index.txt116
-rw-r--r--docs/ref/contrib/contenttypes.txt4
-rw-r--r--docs/ref/databases.txt35
-rw-r--r--docs/ref/django-admin.txt6
-rw-r--r--docs/ref/files/storage.txt4
-rw-r--r--docs/ref/generic-views.txt72
-rw-r--r--docs/ref/index.txt1
-rw-r--r--docs/ref/models/fields.txt30
-rw-r--r--docs/ref/models/querysets.txt4
-rw-r--r--docs/ref/settings.txt16
10 files changed, 193 insertions, 95 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 6719527d2f..64d9c52492 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -347,7 +347,7 @@ A few special cases to note about ``list_display``:
birthday = models.DateField()
def born_in_fifties(self):
- return self.birthday.strftime('%Y')[:3] == 5
+ return self.birthday.strftime('%Y')[:3] == '195'
born_in_fifties.boolean = True
class PersonAdmin(admin.ModelAdmin):
@@ -667,6 +667,43 @@ Controls where on the page the actions bar appears. By default, the admin
changelist displays actions at the top of the page (``actions_on_top = True;
actions_on_bottom = False``).
+.. attribute:: ModelAdmin.change_list_template
+
+Path to a custom template that will be used by the model objects "change list"
+view. Templates can override or extend base admin templates as described in
+`Overriding Admin Templates`_.
+
+If you don't specify this attribute, a default template shipped with Django
+that provides the standard appearance is used.
+
+.. attribute:: ModelAdmin.change_form_template
+
+Path to a custom template that will be used by both the model object creation
+and change views. Templates can override or extend base admin templates as
+described in `Overriding Admin Templates`_.
+
+If you don't specify this attribute, a default template shipped with Django
+that provides the standard appearance is used.
+
+.. attribute:: ModelAdmin.object_history_template
+
+Path to a custom template that will be used by the model object change history
+display view. Templates can override or extend base admin templates as
+described in `Overriding Admin Templates`_.
+
+If you don't specify this attribute, a default template shipped with Django
+that provides the standard appearance is used.
+
+.. attribute:: ModelAdmin.delete_confirmation_template
+
+Path to a custom template that will be used by the view responsible of showing
+the confirmation page when the user decides to delete one or more model
+objects. Templates can override or extend base admin templates as described in
+`Overriding Admin Templates`_.
+
+If you don't specify this attribute, a default template shipped with Django
+that provides the standard appearance is used.
+
``ModelAdmin`` methods
----------------------
@@ -762,6 +799,56 @@ return a subset of objects for this foreign key field based on the user::
This uses the ``HttpRequest`` instance to filter the ``Car`` foreign key field
to only the cars owned by the ``User`` instance.
+Other methods
+~~~~~~~~~~~~~
+
+.. method:: ModelAdmin.add_view(self, request, form_url='', extra_context=None)
+
+Django view for the model instance addition page. See note below.
+
+.. method:: ModelAdmin.change_view(self, request, object_id, extra_context=None)
+
+Django view for the model instance edition page. See note below.
+
+.. method:: ModelAdmin.changelist_view(self, request, extra_context=None)
+
+Django view for the model instances change list/actions page. See note below.
+
+.. method:: ModelAdmin.delete_view(self, request, object_id, extra_context=None)
+
+Django view for the model instance(s) deletion confirmation page. See note below.
+
+.. method:: ModelAdmin.history_view(self, request, object_id, extra_context=None)
+
+Django view for the page that shows the modification history for a given model
+instance.
+
+Unlike the hook-type ``ModelAdmin`` methods detailed in the previous section,
+these five methods are in reality designed to be invoked as Django views from
+the admin application URL dispatching handler to render the pages that deal
+with model instances CRUD operations. As a result, completely overriding these
+methods will significantly change the behavior of the admin application.
+
+One comon reason for overriding these methods is to augment the context data
+that is provided to the template that renders the view. In the following
+example, the change view is overridden so that the rendered template is
+provided some extra mapping data that would not otherwise be available::
+
+ class MyModelAdmin(admin.ModelAdmin):
+
+ # A template for a very customized change view:
+ change_form_template = 'admin/myapp/extras/openstreetmap_change_form.html'
+
+ def get_osm_info(self):
+ # ...
+
+ def change_view(self, request, object_id, extra_context=None):
+ my_context = {
+ 'osm_data': self.get_osm_info(),
+ }
+ return super(MyModelAdmin, self).change_view(request, object_id,
+ extra_context=my_context))
+
``ModelAdmin`` media definitions
--------------------------------
@@ -783,7 +870,7 @@ Adding custom validation to the admin
-------------------------------------
Adding custom validation of data in the admin is quite easy. The automatic admin
-interfaces reuses :mod:`django.forms`, and the ``ModelAdmin`` class gives you
+interface reuses :mod:`django.forms`, and the ``ModelAdmin`` class gives you
the ability define your own form::
class ArticleAdmin(admin.ModelAdmin):
@@ -803,7 +890,9 @@ any field::
It is important you use a ``ModelForm`` here otherwise things can break. See the
:ref:`forms <ref-forms-index>` documentation on :ref:`custom validation
-<ref-forms-validation>` for more information.
+<ref-forms-validation>` and, more specifically, the
+:ref:`model form validation notes <overriding-modelform-clean-method>` for more
+information.
.. _admin-inlines:
@@ -1106,7 +1195,7 @@ directory, our link would appear on every model's change form.
Templates which may be overridden per app or model
--------------------------------------------------
-Not every template in ``contrib\admin\templates\admin`` may be overridden per
+Not every template in ``contrib/admin/templates/admin`` may be overridden per
app or per model. The following can:
* ``app_index.html``
@@ -1131,8 +1220,8 @@ Root and login templates
------------------------
If you wish to change the index or login templates, you are better off creating
-your own ``AdminSite`` instance (see below), and changing the ``index_template``
-or ``login_template`` properties.
+your own ``AdminSite`` instance (see below), and changing the :attr:`AdminSite.index_template`
+or :attr:`AdminSite.login_template` properties.
``AdminSite`` objects
=====================
@@ -1151,6 +1240,21 @@ or add anything you like. Then, simply create an instance of your
Python class), and register your models and ``ModelAdmin`` subclasses
with it instead of using the default.
+``AdminSite`` attributes
+------------------------
+
+.. attribute:: AdminSite.index_template
+
+Path to a custom template that will be used by the admin site main index view.
+Templates can override or extend base admin templates as described in
+`Overriding Admin Templates`_.
+
+.. attribute:: AdminSite.login_template
+
+Path to a custom template that will be used by the admin site login view.
+Templates can override or extend base admin templates as described in
+`Overriding Admin Templates`_.
+
Hooking ``AdminSite`` instances into your URLconf
-------------------------------------------------
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index f814eccaab..94900b3892 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -347,8 +347,8 @@ doesn't work with a
:class:`~django.contrib.contenttypes.generic.GenericRelation`. For example, you
might be tempted to try something like::
- Bookmark.objects.aggregate(Count('tags'))
-
+ Bookmark.objects.aggregate(Count('tags'))
+
This will not work correctly, however. The generic relation adds extra filters
to the queryset to ensure the correct content type, but the ``aggregate`` method
doesn't take them into account. For now, if you need aggregates on generic
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 76a4159235..9a35b6cb8f 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -251,7 +251,7 @@ Here's a sample configuration which uses a MySQL option file::
DATABASE_OPTIONS = {
'read_default_file': '/path/to/my.cnf',
}
-
+
# my.cnf
[client]
database = DATABASE_NAME
@@ -445,10 +445,10 @@ If you're getting this error, you can solve it by:
* Switching to another database backend. At a certain point SQLite becomes
too "lite" for real-world applications, and these sorts of concurrency
errors indicate you've reached that point.
-
- * Rewriting your code to reduce concurrency and ensure that database
+
+ * Rewriting your code to reduce concurrency and ensure that database
transactions are short-lived.
-
+
* Increase the default timeout value by setting the ``timeout`` database
option option::
@@ -457,7 +457,7 @@ If you're getting this error, you can solve it by:
"timeout": 20,
# ...
}
-
+
This will simply make SQLite wait a bit longer before throwing "database
is locked" errors; it won't really do anything to solve them.
@@ -601,3 +601,28 @@ some limitations on the usage of such LOB columns in general:
Oracle. A workaround to this is to keep ``TextField`` columns out of any
models that you foresee performing ``distinct()`` queries on, and to
include the ``TextField`` in a related model instead.
+
+.. _third-party-notes:
+
+Using a 3rd-party database backend
+==================================
+
+In addition to the officially supported databases, there are backends provided
+by 3rd parties that allow you to use other databases with Django:
+
+* `Sybase SQL Anywhere`_
+* `IBM DB2`_
+* `Microsoft SQL Server 2005`_
+* Firebird_
+* ODBC_
+
+The Django versions and ORM features supported by these unofficial backends
+vary considerably. Queries regarding the specific capabilities of these
+unofficial backends, along with any support queries, should be directed to
+the support channels provided by each 3rd party project.
+
+.. _Sybase SQL Anywhere: http://code.google.com/p/sqlany-django/
+.. _IBM DB2: http://code.google.com/p/ibm-db/
+.. _Microsoft SQL Server 2005: http://code.google.com/p/django-mssql/
+.. _Firebird: http://code.google.com/p/django-firebird/
+.. _ODBC: http://code.google.com/p/django-pyodbc/
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 71804cf022..f657db20f4 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -611,7 +611,11 @@ sqlsequencereset <appname appname ...>
Prints the SQL statements for resetting sequences for the given app name(s).
-See http://simon.incutio.com/archive/2004/04/21/postgres for more information.
+Sequences are indexes used by some database engines to track the next available
+number for automatically incremented fields.
+
+Use this command to generate SQL which will fix cases where a sequence is out
+of sync with its automatically incremented field data.
startapp <appname>
------------------
diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt
index 0ca577059e..c8aafa8626 100644
--- a/docs/ref/files/storage.txt
+++ b/docs/ref/files/storage.txt
@@ -43,8 +43,8 @@ modify the filename as necessary to get a unique name. The actual name of the
stored file will be returned.
The ``content`` argument must be an instance of
-:class:`django.db.files.File` or of a subclass of
-:class:`~django.db.files.File`.
+:class:`django.core.files.File` or of a subclass of
+:class:`~django.core.files.File`.
``Storage.delete(name)``
~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/ref/generic-views.txt b/docs/ref/generic-views.txt
index 427ef91090..4752a705a0 100644
--- a/docs/ref/generic-views.txt
+++ b/docs/ref/generic-views.txt
@@ -9,67 +9,18 @@ again and again. In Django, the most common of these patterns have been
abstracted into "generic views" that let you quickly provide common views of
an object without actually needing to write any Python code.
-Django's generic views contain the following:
+A general introduction to generic views can be found in the :ref:`topic guide
+<topics-generic-views>`.
- * A set of views for doing list/detail interfaces.
-
- * A set of views for year/month/day archive pages and associated
- detail and "latest" pages (for example, the Django weblog's year_,
- month_, day_, detail_, and latest_ pages).
-
- * A set of views for creating, editing, and deleting objects.
-
-.. _year: http://www.djangoproject.com/weblog/2005/
-.. _month: http://www.djangoproject.com/weblog/2005/jul/
-.. _day: http://www.djangoproject.com/weblog/2005/jul/20/
-.. _detail: http://www.djangoproject.com/weblog/2005/jul/20/autoreload/
-.. _latest: http://www.djangoproject.com/weblog/
-
-All of these views are used by creating configuration dictionaries in
-your URLconf files and passing those dictionaries as the third member of the
-URLconf tuple for a given pattern. For example, here's the URLconf for the
-simple weblog app that drives the blog on djangoproject.com::
-
- from django.conf.urls.defaults import *
- from django_website.apps.blog.models import Entry
-
- info_dict = {
- 'queryset': Entry.objects.all(),
- 'date_field': 'pub_date',
- }
-
- urlpatterns = patterns('django.views.generic.date_based',
- (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'object_detail', info_dict),
- (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', info_dict),
- (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict),
- (r'^(?P<year>\d{4})/$', 'archive_year', info_dict),
- (r'^$', 'archive_index', info_dict),
- )
-
-As you can see, this URLconf defines a few options in ``info_dict``.
-``'queryset'`` gives the generic view a ``QuerySet`` of objects to use (in this
-case, all of the ``Entry`` objects) and tells the generic view which model is
-being used.
-
-Documentation of each generic view follows, along with a list of all keyword
-arguments that a generic view expects. Remember that as in the example above,
-arguments may either come from the URL pattern (as ``month``, ``day``,
-``year``, etc. do above) or from the additional-information dictionary (as for
-``queryset``, ``date_field``, etc.).
+This reference contains details of Django's built-in generic views, along with
+a list of all keyword arguments that a generic view expects. Remember that
+arguments may either come from the URL pattern or from the ``extra_context``
+additional-information dictionary.
Most generic views require the ``queryset`` key, which is a ``QuerySet``
instance; see :ref:`topics-db-queries` for more information about ``QuerySet``
objects.
-Most views also take an optional ``extra_context`` dictionary that you can use
-to pass any auxiliary information you wish to the view. The values in the
-``extra_context`` dictionary can be either functions (or other callables) or
-other objects. Functions are evaluated just before they are passed to the
-template. However, note that QuerySets retrieve and cache their data when they
-are first evaluated, so if you want to pass in a QuerySet via
-``extra_context`` that is always fresh you need to wrap it in a function or
-lambda that returns the QuerySet.
-
"Simple" generic views
======================
@@ -801,12 +752,12 @@ specify the page number in the URL in one of two ways:
/objects/?page=3
- * To loop over all the available page numbers, use the ``page_range``
- variable. You can iterate over the list provided by ``page_range``
+ * To loop over all the available page numbers, use the ``page_range``
+ variable. You can iterate over the list provided by ``page_range``
to create a link to every page of results.
These values and lists are 1-based, not 0-based, so the first page would be
-represented as page ``1``.
+represented as page ``1``.
For more on pagination, read the :ref:`pagination documentation
<topics-pagination>`.
@@ -818,7 +769,7 @@ As a special case, you are also permitted to use ``last`` as a value for
/objects/?page=last
-This allows you to access the final page of results without first having to
+This allows you to access the final page of results without first having to
determine how many pages there are.
Note that ``page`` *must* be either a valid page number or the value ``last``;
@@ -909,7 +860,7 @@ library <topics-forms-index>` to build and display the form.
**Description:**
A page that displays a form for creating an object, redisplaying the form with
-validation errors (if there are any) and saving the object.
+validation errors (if there are any) and saving the object.
**Required arguments:**
@@ -1137,3 +1088,4 @@ In addition to ``extra_context``, the template's context will be:
variable's name depends on the ``template_object_name`` parameter, which
is ``'object'`` by default. If ``template_object_name`` is ``'foo'``,
this variable's name will be ``foo``.
+
diff --git a/docs/ref/index.txt b/docs/ref/index.txt
index 3ffa1fcce1..6cc796d8e4 100644
--- a/docs/ref/index.txt
+++ b/docs/ref/index.txt
@@ -20,3 +20,4 @@ API Reference
signals
templates/index
unicode
+
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 2ec74e4306..177df12862 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -800,21 +800,22 @@ you can use the name of the model, rather than the model object itself::
class Manufacturer(models.Model):
# ...
-Note, however, that this only refers to models in the same ``models.py`` file --
-you cannot use a string to reference a model defined in another application or
-imported from elsewhere.
-
-.. versionchanged:: 1.0
- Refering models in other applications must include the application label.
+.. versionadded:: 1.0
-To refer to models defined in another
-application, you must instead explicitly specify the application label. For
-example, if the ``Manufacturer`` model above is defined in another application
-called ``production``, you'd need to use::
+To refer to models defined in another application, you can explicitly specify
+a model with the full application label. For example, if the ``Manufacturer``
+model above is defined in another application called ``production``, you'd
+need to use::
class Car(models.Model):
manufacturer = models.ForeignKey('production.Manufacturer')
+This sort of reference can be useful when resolving circular import
+dependencies between two applications.
+
+Database Representation
+~~~~~~~~~~~~~~~~~~~~~~~
+
Behind the scenes, Django appends ``"_id"`` to the field name to create its
database column name. In the above example, the database table for the ``Car``
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.
.. _foreign-key-arguments:
+Arguments
+~~~~~~~~~
+
:class:`ForeignKey` accepts an extra set of arguments -- all optional -- that
define the details of how the relation works.
@@ -871,6 +875,9 @@ the model is related. This works exactly the same as it does for
:class:`ForeignKey`, including all the options regarding :ref:`recursive
<recursive-relationships>` and :ref:`lazy <lazy-relationships>` relationships.
+Database Representation
+~~~~~~~~~~~~~~~~~~~~~~~
+
Behind the scenes, Django creates an intermediary join table to represent the
many-to-many relationship. By default, this table name is generated using the
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
.. _manytomany-arguments:
+Arguments
+~~~~~~~~~
+
:class:`ManyToManyField` accepts an extra set of arguments -- all optional --
that control how the relationship functions.
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 6c08fe079e..348486b341 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -35,7 +35,7 @@ You can evaluate a ``QuerySet`` in the following ways:
* **Slicing.** As explained in :ref:`limiting-querysets`, a ``QuerySet`` can
be sliced, using Python's array-slicing syntax. Usually slicing a
- ``QuerySet`` returns another (unevaluated ) ``QuerySet``, but Django will
+ ``QuerySet`` returns another (unevaluated) ``QuerySet``, but Django will
execute the database query if you use the "step" parameter of slice
syntax.
@@ -616,6 +616,8 @@ call, since they are conflicting options.
Both the ``depth`` argument and the ability to specify field names in the call
to ``select_related()`` are new in Django version 1.0.
+.. _extra:
+
``extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index b5ac651e25..597aeaa89d 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -195,7 +195,7 @@ DATABASE_NAME
Default: ``''`` (Empty string)
The name of the database to use. For SQLite, it's the full path to the database
-file. When specifying the path, always use forward slashes, even on Windows
+file. When specifying the path, always use forward slashes, even on Windows
(e.g. ``C:/homes/user/mysite/sqlite3.db``).
.. setting:: DATABASE_OPTIONS
@@ -228,7 +228,7 @@ The port to use when connecting to the database. An empty string means the
default port. Not used with SQLite.
.. setting:: DATABASE_USER
-
+
DATABASE_USER
-------------
@@ -251,7 +251,7 @@ See also ``DATETIME_FORMAT``, ``TIME_FORMAT``, ``YEAR_MONTH_FORMAT``
and ``MONTH_DAY_FORMAT``.
.. setting:: DATETIME_FORMAT
-
+
DATETIME_FORMAT
---------------
@@ -339,7 +339,7 @@ isn't manually specified. Used with ``DEFAULT_CHARSET`` to construct the
DEFAULT_FILE_STORAGE
--------------------
-Default: ``django.core.files.storage.FileSystemStorage``
+Default: ``'django.core.files.storage.FileSystemStorage'``
Default file storage class to be used for any file-related operations that don't
specify a particular storage system. See :ref:`topics-files`.
@@ -528,14 +528,14 @@ system's standard umask.
.. warning::
**Always prefix the mode with a 0.**
-
+
If you're not familiar with file modes, please note that the leading
``0`` is very important: it indicates an octal number, which is the
way that modes must be specified. If you try to use ``644``, you'll
get totally incorrect behavior.
-
-.. _documentation for os.chmod: http://docs.python.org/lib/os-file-dir.html
+
+.. _documentation for os.chmod: http://docs.python.org/lib/os-file-dir.html
.. setting:: FIXTURE_DIRS
@@ -1162,7 +1162,7 @@ running in the correct environment.
Django cannot reliably use alternate time zones in a Windows environment.
If you're running Django on Windows, this variable must be set to match the
system timezone.
-
+
.. _See available choices: http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
.. setting:: URL_VALIDATOR_USER_AGENT