Get choices of modelchoicefield

linkaiyi
Follow

Customize admin template for ModelChoiceField

{% for field in  inline_admin_formset.fields %}
                        {% if field.name == 'assigned_to' %}
                        <th><select id="task_assigned_to" class="form-control">
{#                                <option value="alle" selected>--Alle--</option>#}
                                {% for value, name in field.widget.widget.choices %}
                                <option value="{{ value }}" {% if forloop.first %}selected{% endif %}>{{ name }}</option>
                                {% endfor %}
                              </select>
                        </th>
                        {% else %}<th></th>
                        {% endif %}
                    {% endfor %}
Object has 0 attachments

Was this article helpful?

This article is viewed 28 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support