djangosnippets.org: Latest snippets posted by cdcarterhttps://djangosnippets.org/users/cdcarter/2024-01-05T14:28:02.916197-06:00cdcarterJSONRequestMiddleware adds a .json() method to your HttpRequests
2024-01-05T14:28:02.916197-06:00cdcarterhttps://djangosnippets.org/snippets/10951/<p>add JSONRequestMiddleware to your enabled middleware in Django settings. Now, in your view functions, you can call request.json() to get a parsed json body! json is consumed lazily, and cached.</p>
Freely redistributableStringField: CharField with no max_length for Postgres
2019-05-05T10:59:12.887442-05:00cdcarterhttps://djangosnippets.org/snippets/10667/<p>Django's CharField requires a max_length, and TextField displays a multi-
line widget, but in Postgres there's no reason to add an arbitrary max
thanks to the <code>varlena</code> storage format. So this is a TextField that
displays as a single line instead of a multiline TextArea.</p>
Freely redistributable