Display a boolean model field in a django form as a radio button rather than the default Checkbox

前端 未结 4 1915
猫巷女王i
猫巷女王i 2021-02-08 06:19

This is how I went about, to display a Boolean model field in the form as Radio buttons Yes and No.

choices = ( (1,\'Yes\'),
            (0,\'No\'),
          )
         


        
4条回答
  •  执笔经年
    2021-02-08 06:30

    Use this if you want the horizontal renderer.

    http://djangosnippets.org/snippets/1956/

提交回复
热议问题