Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use django-widget-tweaks with MultipleChoiceField field? #45

Open
nurzhannogerbek opened this issue May 1, 2017 · 1 comment

Comments

@nurzhannogerbek
Copy link

nurzhannogerbek commented May 1, 2017

1 QUESTION: How to use django-tweaks with MultipleChoiceField field?

2QUESTION: I have form with MultipleChoiceField field which has dynamic list for choices. Sometimes dynamic list can be empty []. So I want to show message in template when its empty but next code didnt show message.

forms.py:

class RequirementForm(forms.ModelForm):
    symbol = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple)

    class Meta:
        model = Requirement
        fields = ('symbol',)

requirement_add.html:

{% load widget_tweaks %}
<form method="post" action="{% url 'project:requirement_add' project_code=project.code %}">
        {% for field in form %}
                {% render_field field class="form-control" %}
        {% empty %}
            <p>Form is empty!</p>
        {% endfor %}
</form>
@nurzhannogerbek nurzhannogerbek changed the title How to use django-tweaks with MultipleChoiceField field? How to use django-widget-tweaks with MultipleChoiceField field? May 1, 2017
@zodman
Copy link
Member

zodman commented May 21, 2020

@zodman zodman closed this as completed May 21, 2020
@zodman zodman reopened this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants