Skip to content

Instantly share code, notes, and snippets.

@jpic
Last active April 17, 2017 01:56
Show Gist options
  • Save jpic/e4f48295ab419d007826d1ab510a77a2 to your computer and use it in GitHub Desktop.
Save jpic/e4f48295ab419d007826d1ab510a77a2 to your computer and use it in GitHub Desktop.
django rest framework django autocomplete light django filter
{# 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 %}
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