python - How to set Content-Type header for 304 http response code? -
so using few decorators django enable caching on api:
@require_get @cache_page(100) @cache_control(max_age=100, s_maxage=100) @csrf_exempt def my_api(request):
the problem is, 304 not modified response coming text/html content-type header. api returns application/json content-type header , consistent. there way tell django content type homecoming 304 response code?
the problem here https://github.com/django/django/blob/master/django/http/response.py#l411
write decorator add together mimetype again
def restoremime(fn): def wrapper(*args, **kwds): response = fn(*args, **kwds) response['content-type'] = your_mime_type homecoming response homecoming wrapper
python django
No comments:
Post a Comment