Commit 3cc28e21 authored by James Pic's avatar James Pic

Merge pull request #15 from political-memory/proposal_autocomplete

Added autocomplete for Proposal
parents bbb804bf c19407cb
from dal import autocomplete
from django.db.models import Q
from models import Proposal
class ProposalAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
qs = Proposal.objects.all()
if self.q:
qs = qs.filter(
Q(dossier__title__icontains=self.q) |
Q(title__icontains=self.q) |
Q(reference__icontains=self.q)
)
return qs
from django.conf import settings
from django.conf.urls import url
import views
......@@ -14,3 +15,14 @@ urlpatterns = [
name='dossier-list'
),
]
if 'dal_select2' in settings.INSTALLED_APPS:
from autocompletes import ProposalAutocomplete # noqa
urlpatterns.append(
url(
'autocomplete/proposal/$',
ProposalAutocomplete.as_view(),
name='proposal-autocomplete',
),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment