Django - Render CheckboxSelectMultiple() widget individually in template (manually)

后端 未结 3 586
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 02:39

I have those two models:

models.py

class App(models.Model):
    app_name = models.SlugField(max_length=50)
    options_loaded = models.ManyToManyFiel         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 03:10

    For those who came here looking to render CheckBoxMultipleSelect manually but in the standard way (the way Django does, using HTML lists), the following is what I came up with (@below-the-radar's solution helped me achieve it)

      {% for pk, choice in field.field.widget.choices %}
    • {% endfor %}

提交回复
热议问题