Django: How to check if field widget is checkbox in the template?

前端 未结 3 1903
一向
一向 2021-01-04 20:09

I\'ve created a custom template for rendering form fields:


    
        <         


        
3条回答
  •  余生分开走
    2021-01-04 20:26

    {{ field.field.widget.input_type }} will get you this info for a lot of widgets, but not all. I'm not sure if it'll work for the default checkbox widget or not. Worth a shot.

提交回复
热议问题