diff --git a/requirements.txt b/requirements.txt index 0b41cd50b..b4e5ff579 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,8 +2,8 @@ # just Django, but for the purposes of development and testing # there are a number of packages that are useful to install. -# Laying these out as seperate requirements files, allows us to -# only included the relevent sets when running tox, and ensures +# Laying these out as separate requirements files, allows us to +# only included the relevant sets when running tox, and ensures # we are only ever declaring our dependencies in one place. -r requirements/requirements-optionals.txt diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index f3695e665..9739a108a 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -91,7 +91,7 @@ class DestroyModelMixin(object): def destroy(self, request, *args, **kwargs): instance = self.get_object() self.perform_destroy(instance) - return Response(status=status.HTTP_204_NO_CONTENT) + return Response(status=status.HTTP_204_NO_CONTENT, content_type=request.content_type) def perform_destroy(self, instance): instance.delete() diff --git a/rest_framework/response.py b/rest_framework/response.py index cb0f290ce..98a3cf3c4 100644 --- a/rest_framework/response.py +++ b/rest_framework/response.py @@ -11,6 +11,7 @@ from django.utils import six from django.utils.six.moves.http_client import responses from rest_framework.serializers import Serializer +from rest_framework.settings import api_settings class Response(SimpleTemplateResponse): @@ -77,7 +78,7 @@ class Response(SimpleTemplateResponse): ) return bytes(ret.encode(charset)) - if not ret: + if api_settings.REMOVE_CONTENT_TYPE_ON_HTTP_204 and not ret: del self['Content-Type'] return ret diff --git a/rest_framework/settings.py b/rest_framework/settings.py index 3f3c9110a..af41fbb28 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -107,6 +107,8 @@ DEFAULTS = { 'TIME_FORMAT': ISO_8601, 'TIME_INPUT_FORMATS': (ISO_8601,), + 'REMOVE_CONTENT_TYPE_ON_HTTP_204': True, + # Encoding 'UNICODE_JSON': True, 'COMPACT_JSON': True,