As introduced in the previous chapter, the “form_layouts” template tag library lets you customize several levels of form rendering. The template tag library searches for templates in a particular directory structure.
The default structure provided by Django-formrenderingtools is:
Every element in the list above is a folder. It contains one default.html template.
If you look at the templates provided by formrenderingtools, you will notice that “templates/form_layouts” also contains the following folders:
These layouts exist for demonstration and migration purposes. They are based on the default layout. You can read the template code to create your own layouts.
Several parameters allow you to change the locations where template selection occurs:
the “layout” parameter of the tags in the “form_layouts” template tag library. You can use whatever you want provided it is a valid directory name, without leading and trailing slashes:
{% form layout="contact_form" %}
{% form layout="user_account/register" %}
The “layout” parameter affects nested elements. It means that using {% form layout=”contact” %} will generate implicit {% field layout=”contact” %} calls.
the “template” parameter of the tags in the “form_layouts” template tag library. You can use whatever you want provided it is a valid file name. Do not forget the extension:
{% form template="contact_form.html" %}
{% form template="user/register.html" %}
The “template” parameter affects only the current element. It means that using {% form template=”contact.html” %} will generate implicit calls with default template, as {% field template=”default.html” %}.
As an example, if you didn’t change the default template and layout names, {% form layout=’LAYOUT/DIR’ template=”TEMPLATE/NAME.html” %} will use the first existing template in the following list:
Similar rules are used for other elements.
Keep in mind that, in general use case, the “layout” and “template” parameters should be enough to get the result you want. The following parameters are documented for contributors: