J
J
JRazor2016-09-18 03:14:06
Django
JRazor, 2016-09-18 03:14:06

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

2 answer(s)
R
Roman Kitaev, 2016-09-18
@JRazor

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.

Z
zelsky, 2016-09-18
@zelsky

Learn to google.
stackoverflow.com/questions/19489699/how-to-add-cl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question