How to add HTML attributes to the form.field from a template?

Hi all.

I'm either bad looking or something else. How to add HTML attributes in the template itself, not from the form class?

In Jinja2 it looks like this:
form.name(placeholder='Name' id='name')

But how is this done in Django without third-party modules? Or maybe at least have the opportunity to get out all of the field data - type, etc., necessary for the layout?
July 4th 19 at 23:36
2 answers
July 4th 19 at 23:38
Solution
Native does. Without third-party modules two options:
1) the form Class. I think that it's awful.
2) Self inclusion_tag

But it is more convenient to use django-widget-tweaks.
The fact of the matter is that layout using form class is just disgusting. I even tried to rape a template and tried to do something with field.field.widget.attrs, but I did not. Django is very disappointing. Who could ever guess to render HTML from a form class? Well, I'll go and write my inclusion_tag. - Jettie88 commented on July 4th 19 at 23:41
July 4th 19 at 23:40
Learn to read. "How to add HTML attributes in the template itself, not from the form class?" - Jettie88 commented on July 4th 19 at 23:43

Find more questions by tags DjangoPython