summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGeorg Bauer <gb@hugo.westfalen.de>2005-10-20 14:15:30 +0000
committerGeorg Bauer <gb@hugo.westfalen.de>2005-10-20 14:15:30 +0000
commit15f1da053220394061d0f37447e545597cee6cd9 (patch)
tree97ea1f3608e7408c21125d13bbbc033c38972091 /docs
parent0ab4ae9349d63f6d40b40709417fa02ffb12f2a9 (diff)
parent169f9d2bd3b8940a0de7cc63c765d5d21eced800 (diff)
i18n: merged to [978] from trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@979 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/model-api.txt15
-rw-r--r--docs/templates.txt79
2 files changed, 84 insertions, 10 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 85d2e58aca..fa6d8f10e6 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -171,7 +171,14 @@ The following arguments are available to all field types. All are optional.
Like ``unique_for_date`` and ``unique_for_month``.
``validator_list``
- A list of extra validators to apply to the field.
+ A list of extra validators to apply to the field. Each should be a callable
+ that takes the parameters ``field_data, all_data`` and raises
+ ``django.core.validators.ValidationError`` for errors. (See the
+ `validator docs`_.)
+
+ Django comes with quite a few validators. They're in ``django.core.validators``.
+
+.. _validator docs: http://www.djangoproject.com/documentation/forms/#validators
Field types
-----------
@@ -237,7 +244,7 @@ Here are all available field types:
``EmailField``
A ``CharField`` that checks that the value is a valid e-mail address.
- Currently, this is a loose test.
+ (Currently, this is a loose test.) This doesn't accept ``maxlength``.
``FileField``
A file-upload field.
@@ -369,8 +376,8 @@ Here are all available field types:
``SlugField``
"Slug" is a newspaper term. A slug is a short label for something,
- containing only letters, numbers and underscores. They're generally used in
- URLs.
+ containing only letters, numbers, underscores or hyphens. They're generally
+ used in URLs.
Implies ``maxlength=50`` and ``db_index=True``.
diff --git a/docs/templates.txt b/docs/templates.txt
index 5c52371c8a..e543b59763 100644
--- a/docs/templates.txt
+++ b/docs/templates.txt
@@ -446,9 +446,9 @@ Built-in tag reference
<h1>Archive for {{ year }}</h1>
- {% for date in days %}
- {% ifchanged %}<h3>{{ date|date:"F" }}</h3>{% endifchanged %}
- <a href="{{ date|date:"M/d"|lower }}/">{{ date|date:"j" }}</a>
+ {% for day in days %}
+ {% ifchanged %}<h3>{{ day|date:"F" }}</h3>{% endifchanged %}
+ <a href="{{ day|date:"M/d"|lower }}/">{{ day|date:"j" }}</a>
{% endfor %}
``ifequal``
@@ -479,13 +479,80 @@ Built-in tag reference
``now``
Display the date, formatted according to the given string.
- Uses the same format as PHP's ``date()`` function; see http://php.net/date
- for all the possible values.
+ Uses the same format as PHP's ``date()`` function (http://php.net/date)
+ with some custom extensions.
- Sample usage::
+ Available format strings:
+
+ ================ ====================================== =====================
+ Format character Description Example output
+ ================ ====================================== =====================
+ a ``'a.m.'`` or ``'p.m.'`` (Note that ``'a.m.'``
+ this is slightly different than PHP's
+ output, because this includes periods
+ to match Associated Press style.)
+ A ``'AM'`` or ``'PM'``. ``'AM'``
+ B Not implemented.
+ d Day of the month, 2 digits with ``'01'`` to ``'31'``
+ leading zeros.
+ D Day of the week, textual, 3 letters. ``'Fri'``
+ f Time, in 12-hour hours and minutes, ``'1'``, ``'1:30'``
+ with minutes left off if they're zero.
+ Proprietary extension.
+ F Month, textual, long. ``'January'``
+ g Hour, 12-hour format without leading ``'1'`` to ``'12'``
+ zeros.
+ G Hour, 24-hour format without leading ``'0'`` to ``'23'``
+ zeros.
+ h Hour, 12-hour format. ``'01'`` to ``'12'``
+ H Hour, 24-hour format. ``'00'`` to ``'23'``
+ i Minutes. ``'00'`` to ``'59'``
+ I Not implemented.
+ j Day of the month without leading ``'1'`` to ``'31'``
+ zeros.
+ l Day of the week, textual, long. ``'Friday'``
+ L Boolean for whether it's a leap year. ``True`` or ``False``
+ m Month, 2 digits with leading zeros. ``'01'`` to ``'12'``
+ M Month, textual, 3 letters. ``'Jan'``
+ n Month without leading zeros. ``'1'`` to ``'12'``
+ N Month abbreviation in Associated Press ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'``
+ style. Proprietary extension.
+ O Not implemented.
+ P Time, in 12-hour hours, minutes and ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'``
+ 'a.m.'/'p.m.', with minutes left off
+ if they're zero and the special-case
+ strings 'midnight' and 'noon' if
+ appropriate. Proprietary extension.
+ r Not implemented.
+ s Seconds, 2 digits with leading zeros. ``'00'`` to ``'59'``
+ S English ordinal suffix for day of the ``'st'``, ``'nd'``, ``'rd'`` or ``'th'``
+ month, 2 characters.
+ t Not implemented.
+ T Not implemented.
+ U Not implemented.
+ w Day of the week, digits without ``'0'`` (Sunday) to ``'6'`` (Saturday)
+ leading zeros.
+ W ISO-8601 week number of year, with ``1``, ``23``
+ weeks starting on Monday.
+ y Year, 2 digits. ``'99'``
+ Y Year, 4 digits. ``'1999'``
+ z Day of the year. ``0`` to ``365``
+ Z Not implemented.
+ ================ ====================================== =====================
+
+ Example::
It is {% now "jS F Y H:i" %}
+ Note that you can backslash-escape a format string if you want to use the
+ "raw" value. In this example, "f" is backslash-escaped, because otherwise
+ "f" is a format string that displays the time. The "o" doesn't need to be
+ escaped, because it's not a format character.::
+
+ It is the {% "jS o\f F" %}
+
+ (Displays "It is the 4th of September" %}
+
``regroup``
Regroup a list of alike objects by a common attribute.