diff --git a/djing/lib/decorators.py b/djing/lib/decorators.py index 587f099..4e608fb 100644 --- a/djing/lib/decorators.py +++ b/djing/lib/decorators.py @@ -99,9 +99,9 @@ def json_view(fn): @wraps(fn) def wrapped(request, *args, **kwargs): r = fn(request, *args, **kwargs) - if 'text' in r.keys() and not isinstance(r['text'], str): + if r and 'text' in r.keys() and not isinstance(r['text'], str): r['text'] = str(r['text']) - return JsonResponse(dict(r), safe=False, json_dumps_params={ + return JsonResponse(dict(r or {'text': 'null'}), safe=False, json_dumps_params={ 'ensure_ascii': False }) return wrapped