Made a bunch of small doc rewordings from changes over the past couple of weeks

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7122 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2008-02-16 05:15:09 +00:00
parent b893eb4d7a
commit 8b3f36029f
6 changed files with 26 additions and 22 deletions

View File

@ -3,7 +3,7 @@ class MergeDict(object):
A simple class for creating new "virtual" dictionaries that actually look A simple class for creating new "virtual" dictionaries that actually look
up values in more than one dictionary, passed in the constructor. up values in more than one dictionary, passed in the constructor.
If a key appears in more than one of the passed in dictionaries, only the If a key appears in more than one of the given dictionaries, only the
first occurrence will be used. first occurrence will be used.
""" """
def __init__(self, *dicts): def __init__(self, *dicts):

View File

@ -323,17 +323,18 @@ parameter when declaring the form field::
Form inheritance Form inheritance
---------------- ----------------
As with the basic forms, you can extend and reuse ``ModelForms`` by inheriting
them. Normally, this will be useful if you need to declare some extra fields As with basic forms, you can extend and reuse ``ModelForms`` by inheriting
or extra methods on a parent class for use in a number of forms derived from them. This is useful if you need to declare extra fields or extra methods on a
models. For example, using the previous ``ArticleForm`` class:: parent class for use in a number of forms derived from models. For example,
using the previous ``ArticleForm`` class::
>>> class EnhancedArticleForm(ArticleForm): >>> class EnhancedArticleForm(ArticleForm):
... def clean_pub_date(self): ... def clean_pub_date(self):
... ... ... ...
This creates a form that behaves identically to ``ArticleForm``, except there This creates a form that behaves identically to ``ArticleForm``, except there's
is some extra validation and cleaning for the ``pub_date`` field. some extra validation and cleaning for the ``pub_date`` field.
You can also subclass the parent's ``Meta`` inner class if you want to change You can also subclass the parent's ``Meta`` inner class if you want to change
the ``Meta.fields`` or ``Meta.excludes`` lists:: the ``Meta.fields`` or ``Meta.excludes`` lists::
@ -342,17 +343,18 @@ the ``Meta.fields`` or ``Meta.excludes`` lists::
... class Meta(ArticleForm.Meta): ... class Meta(ArticleForm.Meta):
... exclude = ['body'] ... exclude = ['body']
This adds in the extra method from the ``EnhancedArticleForm`` and modifies This adds the extra method from the ``EnhancedArticleForm`` and modifies
the original ``ArticleForm.Meta`` to remove one field. the original ``ArticleForm.Meta`` to remove one field.
There are a couple of things to note, however. Most of these won't normally be There are a couple of things to note, however.
of concern unless you are trying to do something tricky with subclassing.
* Normal Python name resolution rules apply. If you have multiple base * Normal Python name resolution rules apply. If you have multiple base
classes that declare a ``Meta`` inner class, only the first one will be classes that declare a ``Meta`` inner class, only the first one will be
used. This means the child's ``Meta``, if it exists, otherwise the used. This means the child's ``Meta``, if it exists, otherwise the
``Meta`` of the first parent, etc. ``Meta`` of the first parent, etc.
* For technical reasons, you cannot have a subclass that is inherited from * For technical reasons, a subclass cannot inherit from both a ``ModelForm``
both a ``ModelForm`` and a ``Form`` simultaneously. and a ``Form`` simultaneously.
Chances are these notes won't affect you unless you're trying to do something
tricky with subclassing.

View File

@ -576,7 +576,7 @@ Three things to note about 404 views:
in the 404. in the 404.
* The 404 view is passed a ``RequestContext`` and will have access to * The 404 view is passed a ``RequestContext`` and will have access to
variables supplied by your ``TEMPLATE_CONTEXT_PROCESSORS`` (e.g. variables supplied by your ``TEMPLATE_CONTEXT_PROCESSORS`` setting (e.g.,
``MEDIA_URL``). ``MEDIA_URL``).
* If ``DEBUG`` is set to ``True`` (in your settings module), then your 404 * If ``DEBUG`` is set to ``True`` (in your settings module), then your 404

View File

@ -30,9 +30,9 @@ Optional arguments
``context_instance`` ``context_instance``
The context instance to render the template with. By default, the template The context instance to render the template with. By default, the template
will be rendered with a ``Context`` instance (filled with values from will be rendered with a ``Context`` instance (filled with values from
``dictionary``). If you need to use `context processors`_, you will want to ``dictionary``). If you need to use `context processors`_, render the
render the template with a ``RequestContext`` instance instead. Your code template with a ``RequestContext`` instance instead. Your code might look
might look something like this:: something like this::
return render_to_response('my_template.html', return render_to_response('my_template.html',
my_data_dictionary, my_data_dictionary,

View File

@ -1406,6 +1406,8 @@ Joins a list with a string, like Python's ``str.join(list)``.
last last
~~~~ ~~~~
**New in Django development version.**
Returns the last item in a list. Returns the last item in a list.
length length

View File

@ -191,12 +191,12 @@ The remaining arguments should be tuples in this format::
`Passing extra options to view functions`_ below.) `Passing extra options to view functions`_ below.)
.. note:: .. note::
Since `patterns()` is a function call, it accepts a maximum of 255 Because `patterns()` is a function call, it accepts a maximum of 255
arguments (URL patterns, in this case). This is a limit for all Python arguments (URL patterns, in this case). This is a limit for all Python
function calls. This will rarely be problem in practice, since you'll function calls. This is rarely a problem in practice, because you'll
typically structure your URL patterns modularly by using `include()` typically structure your URL patterns modularly by using `include()`
sections. However, on the off-chance you do hit the 255-argument limit, sections. However, on the off-chance you do hit the 255-argument limit,
realise that `patterns()` returns a Python list, so you can split up the realize that `patterns()` returns a Python list, so you can split up the
construction of the list. construction of the list.
:: ::
@ -209,8 +209,8 @@ The remaining arguments should be tuples in this format::
) )
Python lists have unlimited size, so there's no limit to how many URL Python lists have unlimited size, so there's no limit to how many URL
patterns you can construct; merely that you may only create 254 at a time patterns you can construct. The only limit is that you can only create 254
(the 255-th argument is the initial prefix argument). at a time (the 255th argument is the initial prefix argument).
url url
--- ---