Commit c19407cb authored by Jamesie Pic's avatar Jamesie Pic

Added autocomplete for Proposal

parent bbb804bf
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