Migrate from Django’s builtins to djc.formrenderingtool

django-formrenderingtools and it fits your needs? How to safely migrate an existing project from standard Django’s practices to formrenderingtools? Here are some guidelines.

Replace {{ form }} by {% form %} in your templates

In the templates you edit (i.e. you should not patch Django code or code of any third-party application), 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” %}

Experimental

Use Form subclass which overrides default rendering methods

Such a class is not yet included in django-formrenderingtools. The idea is to instantiate forms which inherit from “SomeFormRenderingToolsCompatibleForm” base class which overrides default Form.__unicode__(), Form.as_table(), Form.as_p() and Form.as_ul().

This could be useful in some cases where:

  • you control the Form class, but not the templates (you pass a Form instance to a third-party application.
  • your application defines specific form class which is used by other modules.

The main drawback is that you need to edit Python code to perform template- related changes.