The “form tools” app — django-formtools dev documentation (original) (raw)
- Docs »
- The “form tools” app
- Edit on GitHub
django-formtools is a collection of assorted utilities that are useful for specific form use cases.
Currently there are two tools: a helper for form previews and a form wizard view.
- Form preview
- Form wizard
- How it works
- Usage
* Defining Form classes
* Creating a WizardView subclass
* Creating templates for the forms
* Hooking the wizard into a URLconf
* Using a different template for each form - Advanced WizardView methods
- Providing initial data for the forms
- Handling files
- Conditionally view/skip specific steps
- How to work with ModelForm and ModelFormSet
- Usage of NamedUrlWizardView
- Advanced NamedUrlWizardView methods
- Changelog
Installation¶
To install django-formtools use your favorite packaging tool, e.g.pip:
pip install django-formtools
Or download the source distribution from PyPI athttps://pypi.python.org/pypi/django-formtools, decompress the file and run python setup.py install
in the unpacked directory.
Then add 'formtools'
to your INSTALLED_APPS setting:
INSTALLED_APPS = ( # ... 'formtools', )
Note
Adding 'formtools'
to your INSTALLED_APPS
setting is required for translations and templates to work. Using django-formtools without adding it to your INSTALLED_APPS
setting is not recommended.
Internationalization¶
Formtools has its own catalog of translations, in the directoryformtools/locale
, and it’s not loaded automatically like Django’s general catalog in django/conf/locale
. If you want formtools’s texts to be translated, like the templates, you must includeformtools in the INSTALLED_APPS setting, so the internationalization system can find the catalog, as explained inHow Django discovers translations.
Releases¶
New releases of django-formtools should always be compatible with the latest stable release of Django. If a new version of Django contains backwards incompatible changes that affect formtools, a new release of formtools will be issued shortly after the release of the new Django version. Version numbers follow the appropriate Python standards, e.g. PEPs 386 and440.
How to migrate¶
If you’ve used the old django.contrib.formtools
package follow these two easy steps to update your code:
- Install the third-party
django-formtools
package. - Change your app’s import statements to reference the new packages.
For example, change this:
from django.contrib.formtools.wizard.views import WizardView
…to this:
from formtools.wizard.views import WizardView
The code in the new package is the same (it was copied directly from Django), so you don’t have to worry about backwards compatibility in terms of functionality. Only the imports have changed.