Last active
April 17, 2017 01:56
-
-
Save jpic/e4f48295ab419d007826d1ab510a77a2 to your computer and use it in GitHub Desktop.
django rest framework django autocomplete light django filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# in templates/django_filters/rest_framework/crispy_form.html ensure you load jquery.js #} | |
{% load i18n %} | |
{% load crispy_forms_tags %} | |
{% load static %} | |
<script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script> | |
<h2>{% trans "Field filters" %}</h2> | |
{% crispy filter.form %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostFilter(FilterSet): | |
poster = django_filters.ModelMultipleChoiceFilter( | |
queryset=Poster.objects.all(), | |
widget=autocomplete.ModelSelect2Multiple(url='posts:poster_autocomplete'), | |
) | |
class Meta: | |
model = Post | |
fields = [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment