Added code to catch a form error regularly caused by form spam and return a failure instead of triggering a server 500.
- Legacy-Id: 16728
This commit is contained in:
parent
81bc17533a
commit
3160f55597
|
@ -89,7 +89,10 @@ class SearchableDocumentsField(forms.CharField):
|
|||
value = super(SearchableDocumentsField, self).clean(value)
|
||||
pks = self.parse_select2_value(value)
|
||||
|
||||
objs = self.model.objects.filter(pk__in=pks)
|
||||
try:
|
||||
objs = self.model.objects.filter(pk__in=pks)
|
||||
except ValueError as e:
|
||||
raise forms.ValidationError("Unexpected field value; %s" % e)
|
||||
|
||||
found_pks = [ str(o.pk) for o in objs ]
|
||||
failed_pks = [ x for x in pks if x not in found_pks ]
|
||||
|
|
Loading…
Reference in a new issue