Answer the question
In order to leave comments, you need to log in
How to add HTML attributes to form.field from template?
Hi all.
I either searched badly, or something else. How to add HTML attributes in the template itself, not from the form class?
In Jinja2 it looks something like this:
But how is it done in Django without third party modules? Or maybe at least there is an opportunity to get all the data from the field - type and so on, necessary for layout? form.name(placeholder='Name', id='name')
Answer the question
In order to leave comments, you need to log in
Not natively. Without third-party modules, two options:
1) Form class. I think it's terrible.
2) Own inclusion_tag
But it's more convenient to use django-widget-tweaks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question