| 5 | | ``django.forms`` is Django's fantastic new form-handling library. It's a |
|---|
| 6 | | replacement for the old form/manipulator/validation framework, which has been |
|---|
| 7 | | moved to ``django.oldforms``. This document explains how to use this new |
|---|
| 8 | | library. |
|---|
| 9 | | |
|---|
| 10 | | Migration plan |
|---|
| 11 | | ============== |
|---|
| 12 | | |
|---|
| 13 | | ``django.newforms`` is new in Django's 0.96 release, but, as it won't be new |
|---|
| 14 | | forever, we plan to rename it to ``django.forms`` in the future. The current |
|---|
| 15 | | ``django.forms`` package will be available as ``django.oldforms`` until Django |
|---|
| 16 | | 1.0, when we plan to remove it for good. |
|---|
| 17 | | |
|---|
| 18 | | That has direct repercussions on the forward compatibility of your code. Please |
|---|
| 19 | | read the following migration plan and code accordingly: |
|---|
| 20 | | |
|---|
| 21 | | * The old forms framework (the current ``django.forms``) has been copied to |
|---|
| 22 | | ``django.oldforms``. Thus, you can start upgrading your code *now*, |
|---|
| 23 | | rather than waiting for the future backwards-incompatible change, by |
|---|
| 24 | | changing your import statements like this:: |
|---|
| 25 | | |
|---|
| 26 | | from django import forms # old |
|---|
| 27 | | from django import oldforms as forms # new |
|---|
| 28 | | |
|---|
| 29 | | * In the next Django release (0.97), we will move the current |
|---|
| 30 | | ``django.newforms`` to ``django.forms``. This will be a |
|---|
| 31 | | backwards-incompatible change, and anybody who is still using the old |
|---|
| 32 | | version of ``django.forms`` at that time will need to change their import |
|---|
| 33 | | statements, as described in the previous bullet. |
|---|
| 34 | | |
|---|
| 35 | | * We will remove ``django.oldforms`` in the release *after* the next Django |
|---|
| 36 | | release -- either 0.98 or 1.0, whichever comes first. |
|---|
| 37 | | |
|---|
| 38 | | With this in mind, we recommend you use the following import statement when |
|---|
| 39 | | using ``django.newforms``:: |
|---|
| 40 | | |
|---|
| 41 | | from django import newforms as forms |
|---|
| 42 | | |
|---|
| 43 | | This way, your code can refer to the ``forms`` module, and when |
|---|
| 44 | | ``django.newforms`` is renamed to ``django.forms``, you'll only have to change |
|---|
| 45 | | your ``import`` statements. |
|---|
| 46 | | |
|---|
| 47 | | If you prefer "``import *``" syntax, you can do the following:: |
|---|
| 48 | | |
|---|
| 49 | | from django.newforms import * |
|---|
| 50 | | |
|---|
| 51 | | This will import all fields, widgets, form classes and other various utilities |
|---|
| 52 | | into your local namespace. Some people find this convenient; others find it |
|---|
| 53 | | too messy. The choice is yours. |
|---|
| | 5 | ``django.forms`` is Django's form-handling library. |
|---|
| | 6 | |
|---|
| | 7 | .. adminition:: Looking for oldforms? |
|---|
| | 8 | |
|---|
| | 9 | ``django.forms`` was once called ``newforms`` since it replaced Django's |
|---|
| | 10 | original form/manipulator/validation framework. The old form handling |
|---|
| | 11 | library is still available as `django.oldforms`_, but will be removed |
|---|
| | 12 | in a future version of Django. |
|---|
| | 13 | |
|---|
| | 14 | .. _django.oldforms: ../oldforms/ |
|---|