.
This commit is contained in:
+6
-1
@@ -6,7 +6,7 @@ from django import forms
|
|||||||
# from django.contrib.auth.models import User
|
# from django.contrib.auth.models import User
|
||||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import FieldError, PermissionDenied
|
||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.views.generic.detail import DetailView
|
from django.views.generic.detail import DetailView
|
||||||
@@ -1012,6 +1012,11 @@ class StructureAutocomplete(autocomplete.Select2QuerySetView):
|
|||||||
qs = Structure.objects.all()
|
qs = Structure.objects.all()
|
||||||
|
|
||||||
if self.q:
|
if self.q:
|
||||||
|
# This raises a fielderror which breaks creating a new item if not caught
|
||||||
|
try:
|
||||||
qs = qs.filter(name__istartswith=self.q)
|
qs = qs.filter(name__istartswith=self.q)
|
||||||
|
except FieldError:
|
||||||
|
return Structure.objects.none()
|
||||||
|
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|||||||
Reference in New Issue
Block a user