Migrate from Django’s builtins to django-formrenderingtools¶
How to safely migrate an existing project from standard Django’s practices to django-formrenderingtools? Here are some guidelines.
Install django-formrenderingtools¶
See Installation for details.
Replace {{ form }} by {% form %} in your templates¶
In the templates you edit, feel free to replace any:
{{ form }}by{% form layout="as_table" %}{{ form.as_p }}by{% form layout="as_p" %}{{ form.as_ul }}by{% form layout="as_ul" %}{{ form.as_table }}by{% form layout="as_table" %}
Note
django-formrenderingtools’ builtin “as_*” layouts reproduce Django’s behavior. Tests are written to check this fact.
Migrate custom layouts and includes¶
Search for any {{ form.* }} occurrence in templates. You should be able to
replace these occurrence with some django-formrenderingtools features.
If you already used snippets via {% include %}, you should consider
migrating the templates to django-formrenderingtools (see
Template names and directory structure):
- it proposes a convention of directory structure;
- if new features (such as template loading optimizations) are released, you’ll automatically get them.