简体   繁体   中英

How to detect type of Form Field in Template in Django

Hi guys i have simple Django Form , but I need to get type of this field elements and I made some special operations according to this.

Is there an easy way to get type of Form Field in Django Template?

Any help will be appreciated.

For your actual use case the image widget from the django-form-utils package should be a good match.

On more general level: If you simply want to modify the html generated by a standard widget you should subclass the widget and tweak the render-method.

Take a look at this blog post to get the basic idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM