Error clean up, error catching, require django <1.9

* cleaning up the error format in this function to match
  our standard format.
* Catching an error that can occur if the json is improperly decoded.
* fixing Django to the LTS support version as 1.9.1 breaks our automatic
  api documentation.

Change-Id: Ib3e452427989b376c55710ce33f73fabdc84260d
This commit is contained in:
adriant 2016-02-24 17:41:01 +13:00
parent b76c3af1f6
commit e8ff4a1c40
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
Django>=1.8.9
Django>=1.8.9,<1.9
decorator>=3.4.0
djangorestframework>=3.0.3
keystonemiddleware>=1.3.1

View File

@ -684,9 +684,13 @@ class TokenDetail(APIViewWithLogger):
data[field] = request.data[field]
except KeyError:
errors[field] = ["This field is required.", ]
except TypeError:
errors = ["Improperly formated json. " +
"Should be a key-value object.", ]
break
if errors:
return Response(errors, status=400)
return Response({"errors": errors}, status=400)
for action in actions:
try: