Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add compatibilty for mimetype on HttpResponse
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django import VERSION | ||
from django.http import (HttpResponse as BaseHttpResponse, | ||
HttpResponseBadRequest as Base400) | ||
|
||
# https://github.com/chicagobuss/graphite-web/commit/842944a34085c4b6bd5f37532118be996a0ff4f1 | ||
class ContentTypeMixin(object): | ||
def __init__(self, *args, **kwargs): | ||
if VERSION < (1, 5) and 'content_type' in kwargs: | ||
kwargs['mimetype'] = kwargs.pop('content_type') | ||
elif VERSION > (1, 7) and 'mimetype' in kwargs: | ||
kwargs['content_type'] = kwargs.pop('mimetype') | ||
super(ContentTypeMixin, self).__init__(*args, **kwargs) | ||
|
||
class HttpResponse(ContentTypeMixin, BaseHttpResponse): | ||
pass | ||
|
||
class HttpResponseBadRequest(ContentTypeMixin, Base400): | ||
pass |