Show nicer warning when `ujson` isn't installed (#728)

This commit is contained in:
Jake Howard 2019-11-22 11:22:15 +00:00 committed by Tom Christie
parent 4152533ce4
commit 338d5ab0ae
1 changed files with 1 additions and 0 deletions

View File

@ -156,6 +156,7 @@ class UJSONResponse(JSONResponse):
media_type = "application/json" media_type = "application/json"
def render(self, content: typing.Any) -> bytes: def render(self, content: typing.Any) -> bytes:
assert ujson is not None, "ujson must be installed to use UJSONResponse"
return ujson.dumps(content, ensure_ascii=False).encode("utf-8") return ujson.dumps(content, ensure_ascii=False).encode("utf-8")