|
|
|
|
|
by the__alchemist
821 days ago
|
|
I like the automatic model serializers, but don't like the extra layer of syntax in views, ie different than normal Django. DRF's system can be replaced in many cases by these helper functions: def return_json(msg: dict) -> HttpResponse:
return HttpResponse(json.dumps(msg), content_type="application/json")
def load_body(request: HttpRequest) -> dict:
return json.loads(request.body.decode("utf-8"))
This avoids the cognitive overhead of layering another syntax on top of Django's own conventions. |
|