3👍
✅
Ok Solution was simple. In my from file I have added
from django.db.models.fields import BLANK_CHOICE_DASH
and updated the form
class PaymentRangeForm(forms.Form):
start_date = forms.DateField(widget=forms.TextInput(attrs={'type': 'date'} ))
end_date = forms.DateField(widget=forms.TextInput(attrs={'type': 'date'} ))
building = forms.ChoiceField(choices=BLANK_CHOICE_DASH + list(Building.objects.values_list('id', 'name')), required=False)
0👍
load crispy_forms_tags top of the template.
{% load crispy_forms_tags %}
<form method="POST" class="form" action="" method="get">
{% csrf_token %}
{{ form|crispy}}
<br>
<button type="submit" class="btn btn-primary btn-primary">Search</button>
</form>
- [Django]-A production ready server to serve django on win32
- [Django]-Reverse for 'api' not found. 'api' is not a valid view function or pattern name with rest-framework
-1👍
According to Django, perhaps you could try it out without the .all() as below
choices=Building.objects.values_list(‘id’, ‘name’)
- [Django]-Hook to perform actions after loaddata command (loading fixtures)
- [Django]-How to send error message from Django DeleteView?
- [Django]-Learning Django with Python 3?
Source:stackexchange.com