Commit 8b3f3602 authored by Adrian Holovaty's avatar Adrian Holovaty
Browse files

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
parent b893eb4d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ class MergeDict(object):
    A simple class for creating new "virtual" dictionaries that actually look
    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.
    """
    def __init__(self, *dicts):
+14 −12
Original line number Diff line number Diff line
@@ -323,17 +323,18 @@ parameter when declaring the form field::

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
or extra methods on a parent class for use in a number of forms derived from
models. For example, using the previous ``ArticleForm`` class::

As with basic forms, you can extend and reuse ``ModelForms`` by inheriting
them. This is useful if you need to declare extra fields or extra methods on a
parent class for use in a number of forms derived from models. For example,
using the previous ``ArticleForm`` class::

    >>> class EnhancedArticleForm(ArticleForm):
    ...     def clean_pub_date(self):
    ...         ...

This creates a form that behaves identically to ``ArticleForm``, except there
is some extra validation and cleaning for the ``pub_date`` field.
This creates a form that behaves identically to ``ArticleForm``, except there's
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
the ``Meta.fields`` or ``Meta.excludes`` lists::
@@ -342,17 +343,18 @@ the ``Meta.fields`` or ``Meta.excludes`` lists::
    ...     class Meta(ArticleForm.Meta):
    ...         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.

There are a couple of things to note, however. Most of these won't normally be
of concern unless you are trying to do something tricky with subclassing.
There are a couple of things to note, however.

 * Normal Python name resolution rules apply. If you have multiple base
   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
   ``Meta`` of the first parent, etc.

 * For technical reasons, you cannot have a subclass that is inherited from
   both a ``ModelForm`` and a ``Form`` simultaneously.
 * For technical reasons, a subclass cannot inherit from both a ``ModelForm``
   and a ``Form`` simultaneously.

Chances are these notes won't affect you unless you're trying to do something
tricky with subclassing.
+1 −1
Original line number Diff line number Diff line
@@ -576,7 +576,7 @@ Three things to note about 404 views:
      in the 404.

    * 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``).

    * If ``DEBUG`` is set to ``True`` (in your settings module), then your 404
+3 −3
Original line number Diff line number Diff line
@@ -30,9 +30,9 @@ Optional arguments
``context_instance``
    The context instance to render the template with. By default, the template
    will be rendered with a ``Context`` instance (filled with values from
    ``dictionary``). If you need to use `context processors`_, you will want to
    render the template with a ``RequestContext`` instance instead. Your code
    might look something like this::
    ``dictionary``). If you need to use `context processors`_, render the
    template with a ``RequestContext`` instance instead. Your code might look
    something like this::

        return render_to_response('my_template.html',
                                  my_data_dictionary,
+2 −0
Original line number Diff line number Diff line
@@ -1406,6 +1406,8 @@ Joins a list with a string, like Python's ``str.join(list)``.
last
~~~~

**New in Django development version.**

Returns the last item in a list.

length
Loading