mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
[soc2009/model-validation] Merged to trunk at r11155
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11158 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -397,16 +397,26 @@ to be rendered first, we could specify the following ``ModelForm``::
|
||||
... model = Book
|
||||
... fields = ['title', 'author']
|
||||
|
||||
.. _overriding-modelform-clean-method:
|
||||
|
||||
Overriding the clean() method
|
||||
-----------------------------
|
||||
|
||||
You can override the ``clean()`` method on a model form to provide additional
|
||||
validation in the same way you can on a normal form. However, by default the
|
||||
``clean()`` method validates the uniqueness of fields that are marked as
|
||||
``unique``, ``unique_together`` or ``unique_for_date|month|year`` on the model.
|
||||
Therefore, if you would like to override the ``clean()`` method and maintain the
|
||||
default validation, you must call the parent class's ``clean()`` method.
|
||||
validation in the same way you can on a normal form.
|
||||
|
||||
In this regard, model forms have two specific characteristics when compared to
|
||||
forms:
|
||||
|
||||
By default the ``clean()`` method validates the uniqueness of fields that are
|
||||
marked as ``unique``, ``unique_together`` or ``unique_for_date|month|year`` on
|
||||
the model. Therefore, if you would like to override the ``clean()`` method and
|
||||
maintain the default validation, you must call the parent class's ``clean()``
|
||||
method.
|
||||
|
||||
Also, a model form instance bound to a model object will contain a
|
||||
``self.instance`` attribute that gives model form methods access to that
|
||||
specific model instance.
|
||||
|
||||
Form inheritance
|
||||
----------------
|
||||
|
||||
@@ -978,15 +978,17 @@ message files (``.po``). Translation work itself just involves editing existing
|
||||
files of this type, but if you want to create your own message files, or want to
|
||||
test or compile a changed message file, you will need the ``gettext`` utilities:
|
||||
|
||||
* Download the following zip files from
|
||||
http://sourceforge.net/projects/gettext
|
||||
* Download the following zip files from the GNOME servers
|
||||
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/ or from one
|
||||
of its mirrors_
|
||||
|
||||
* ``gettext-runtime-X.bin.woe32.zip``
|
||||
* ``gettext-tools-X.bin.woe32.zip``
|
||||
* ``libiconv-X.bin.woe32.zip``
|
||||
* ``gettext-runtime-X.zip``
|
||||
* ``gettext-tools-X.zip``
|
||||
|
||||
* Extract the 3 files in the same folder (i.e. ``C:\Program
|
||||
Files\gettext-utils``)
|
||||
``X`` is the version number, we recomend using ``0.15`` or higher.
|
||||
|
||||
* Extract the contents of the ``bin\`` directories in both files to the
|
||||
same folder on your system (i.e. ``C:\Program Files\gettext-utils``)
|
||||
|
||||
* Update the system PATH:
|
||||
|
||||
@@ -995,6 +997,8 @@ test or compile a changed message file, you will need the ``gettext`` utilities:
|
||||
* Add ``;C:\Program Files\gettext-utils\bin`` at the end of the
|
||||
``Variable value`` field
|
||||
|
||||
.. _mirrors: http://ftp.gnome.org/pub/GNOME/MIRRORS
|
||||
|
||||
You may also use ``gettext`` binaries you have obtained elsewhere, so long as
|
||||
the ``xgettext --version`` command works properly. Some version 0.14.4 binaries
|
||||
have been found to not support this command. Do not attempt to use Django
|
||||
|
||||
@@ -61,13 +61,27 @@ for each platform.
|
||||
Get your database running
|
||||
=========================
|
||||
|
||||
If you plan to use Django's database API functionality, you'll need to
|
||||
make sure a database server is running. Django works with PostgreSQL_,
|
||||
MySQL_, Oracle_ and SQLite_ (although SQLite doesn't require a separate server
|
||||
to be running).
|
||||
If you plan to use Django's database API functionality, you'll need to make
|
||||
sure a database server is running. Django supports many different database
|
||||
servers and is officially supported with PostgreSQL_, MySQL_, Oracle_ and
|
||||
SQLite_ (although SQLite doesn't require a separate server to be running).
|
||||
|
||||
Additionally, you'll need to make sure your Python database bindings are
|
||||
installed.
|
||||
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.
|
||||
|
||||
In addition to a database backend, you'll need to make sure your Python
|
||||
database bindings are installed.
|
||||
|
||||
* If you're using PostgreSQL, you'll need the psycopg_ package. Django supports
|
||||
both version 1 and 2. (When you configure Django's database layer, specify
|
||||
@@ -89,6 +103,9 @@ installed.
|
||||
:ref:`Oracle backend <oracle-notes>` for important information
|
||||
regarding supported versions of both Oracle and ``cx_Oracle``.
|
||||
|
||||
* If you're using an unofficial 3rd party backend, please consult the
|
||||
documentation provided for any additional requirements.
|
||||
|
||||
If you plan to use Django's ``manage.py syncdb`` command to
|
||||
automatically create database tables for your models, you'll need to
|
||||
ensure that Django has permission to create and alter tables in the
|
||||
@@ -111,7 +128,11 @@ Django will need permission to create a test database.
|
||||
.. _pysqlite: http://pysqlite.org/
|
||||
.. _cx_Oracle: http://cx-oracle.sourceforge.net/
|
||||
.. _Oracle: http://www.oracle.com/
|
||||
|
||||
.. _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/
|
||||
.. _removing-old-versions-of-django:
|
||||
|
||||
Remove any old versions of Django
|
||||
|
||||
Reference in New Issue
Block a user