In Django is there a way to display choices as checkboxes?

前端 未结 2 900
离开以前
离开以前 2020-12-12 15:16

In the admin interface and newforms there is the brilliant helper of being able to define choices. You can use code like this:

APPROVAL_CHOICES = (
    (\'ye         


        
2条回答
  •  攒了一身酷
    2020-12-12 15:45

    @JonnyBuchanan gave the right answer.

    But if you need this in the django admin for many models, and you're (like me) too lazy to customize a ModelForm and ovverride the right methods inside the ModelAdmin class, you can use this approach:

    http://www.abidibo.net/blog/2013/04/10/convert-select-multiple-widget-checkboxes-django-admin-form/

提交回复
热议问题