[Python] implementing checkboxes with multiple select in django admin and modelform?

Discussão em 'Python' iniciado por Stack, Julho 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm fairly new to Django, so I couldn't find a way to implement checkboxes with multiple select in to my custom modelforms and Django admin. I tried the Django docs, but still couldn't find a solution. [​IMG] TIA

    views.py:

    class ProjectCreate(CreateView):
    model = Project
    fields = ['projectid', 'title', 'description', 'startdate', 'enddate', 'cost', 'Project_type',
    'employeeid', 'technologies', 'clientid', 'document']

    class ProjectUpdate(UpdateView):
    model = Project
    fields = ['projectid', 'title', 'description', 'startdate', 'enddate', 'cost', 'Project_type',
    'employeeid', 'technologies', 'clientid']


    form-template.py:

    {% for fields in form %}
    <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
    <span class="text-danger small">{{ fields.errors }}</span>
    </div>
    <label class="control-label col-sm-2">{{ fields.label_tag }}</label>
    <div class="col-sm-10">{{ fields }}</div>
    </div>
    {% endfor %}

    Continue reading...

Compartilhe esta Página