Customize layout of Django forms in templates, not in Python code.
Rather than using {{ form.as_p }} and Python code, set up and reuse templates to render Django’s form elements.
As an example, to reproduce Django’s {{ form.as_p }}:
{% load form_layouts %}
<form>
{% form layout="as_p" %}
<input type="submit">
</form>
For the impatient, jump to the Demo project to discover and try the application in a sandbox.
Note
Django-formrenderingtools is not intended to customize widgets. Have a look at django-floppyforms for this purpose.