from django_select2 import *
class UserChoices(ModelSelect2MultipleField):
queryset = FreeDay.objects
search_fields = ['word__icontains', ]
class FreeDaysForm(InlineForm):
user = UserChoices()
class Meta:
model = FreeDay
class FreeDaysFilter(django_filters.FilterSet):
blank_choice = (('', ugettext_lazy('---')),)
date_from = django_filters.DateFilter(widget=DateInput(attrs={'class':'datepicker'}))
date_to = django_filters.DateFilter(widget=DateInput(attrs={'class':'datepicker'}))
class Meta:
model = FreeDay
form = FreeDaysForm
fields = ['user', 'country', 'date_from', 'date_to']
class DashboardView(TableFilterView):
"""
Displays a list and filter on the main page.
"""
model = FreeDay
table_class = FreeDaysTable
template_name = "freedays/list_of_freedays.html"
context_object_name = 'free_days'
filterset_class = FreeDaysFilter
def get_context_data(self, **kwargs):
context = super(DashboardView, self).get_context_data(**kwargs)
f = FreeDaysForm()
context['f'] = f
return contextIn the template I have:
{% load django_select2_tags %} {% import_django_select2_js %} {% import_django_select2_css %} {% import_django_select2_js_css light=1 %}
--
You received this message because you are subscribed to the Google Groups "django-filter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-filte...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.