diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-01-31 13:39:29 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-01-31 13:54:40 +0100 |
| commit | 89cb771be7b53c40642872cdbedb15943bdf8e34 (patch) | |
| tree | 43b9e7addfe0d5f2ad99a569507f4c19562e4aef /docs | |
| parent | b2039d39d537340c1617f23d68b3f40f070e01db (diff) | |
Fixed #19692 -- Completed deprecation of mimetype in favor of content_type.
Thanks Tim for the report and initial patch.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/howto/outputting-csv.txt | 6 | ||||
| -rw-r--r-- | docs/howto/outputting-pdf.txt | 4 | ||||
| -rw-r--r-- | docs/internals/deprecation.txt | 10 | ||||
| -rw-r--r-- | docs/ref/contrib/admin/actions.txt | 4 | ||||
| -rw-r--r-- | docs/ref/template-response.txt | 36 | ||||
| -rw-r--r-- | docs/topics/http/shortcuts.txt | 13 |
6 files changed, 45 insertions, 28 deletions
diff --git a/docs/howto/outputting-csv.txt b/docs/howto/outputting-csv.txt index bcc6f3827b..1f9efb5a4b 100644 --- a/docs/howto/outputting-csv.txt +++ b/docs/howto/outputting-csv.txt @@ -20,7 +20,7 @@ Here's an example:: def some_view(request): # Create the HttpResponse object with the appropriate CSV header. - response = HttpResponse(mimetype='text/csv') + response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="somefilename.csv"' writer = csv.writer(response) @@ -92,7 +92,7 @@ Here's an example, which generates the same CSV file as above:: def some_view(request): # Create the HttpResponse object with the appropriate CSV header. - response = HttpResponse(mimetype='text/csv') + response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="somefilename.csv"' # The data is hard-coded here, but you could load it from a database or @@ -111,7 +111,7 @@ Here's an example, which generates the same CSV file as above:: The only difference between this example and the previous example is that this one uses template loading instead of the CSV module. The rest of the code -- -such as the ``mimetype='text/csv'`` -- is the same. +such as the ``content_type='text/csv'`` -- is the same. Then, create the template ``my_template_name.txt``, with this template code: diff --git a/docs/howto/outputting-pdf.txt b/docs/howto/outputting-pdf.txt index 9d87b97710..d15f94f7f4 100644 --- a/docs/howto/outputting-pdf.txt +++ b/docs/howto/outputting-pdf.txt @@ -51,7 +51,7 @@ Here's a "Hello World" example:: def some_view(request): # Create the HttpResponse object with the appropriate PDF headers. - response = HttpResponse(mimetype='application/pdf') + response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"' # Create the PDF object, using the response object as its "file." @@ -120,7 +120,7 @@ Here's the above "Hello World" example rewritten to use :mod:`io`:: def some_view(request): # Create the HttpResponse object with the appropriate PDF headers. - response = HttpResponse(mimetype='application/pdf') + response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"' buffer = BytesIO() diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 63d65d1e4a..da0d1e212c 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -290,8 +290,14 @@ these changes. specified as a plain string instead of a tuple will be removed and raise an exception. -* The ``mimetype`` argument to :class:`~django.http.HttpResponse` ``__init__`` - will be removed (``content_type`` should be used instead). +* The ``mimetype`` argument to the ``__init__`` methods of + :class:`~django.http.HttpResponse`, + :class:`~django.template.response.SimpleTemplateResponse`, and + :class:`~django.template.response.TemplateResponse`, will be removed. + ``content_type`` should be used instead. This also applies to the + :func:`~django.shortcuts.render_to_response` shortcut and + the sitemamp views, :func:`~django.contrib.sitemaps.views.index` and + :func:`~django.contrib.sitemaps.views.sitemap`. * When :class:`~django.http.HttpResponse` is instantiated with an iterator, or when :attr:`~django.http.HttpResponse.content` is set to an iterator, diff --git a/docs/ref/contrib/admin/actions.txt b/docs/ref/contrib/admin/actions.txt index d7eef623d5..0a302ecd1d 100644 --- a/docs/ref/contrib/admin/actions.txt +++ b/docs/ref/contrib/admin/actions.txt @@ -223,7 +223,7 @@ objects as JSON:: from django.core import serializers def export_as_json(modeladmin, request, queryset): - response = HttpResponse(mimetype="text/javascript") + response = HttpResponse(content_type="application/json") serializers.serialize("json", queryset, stream=response) return response @@ -356,5 +356,3 @@ Conditionally enabling or disabling actions if 'delete_selected' in actions: del actions['delete_selected'] return actions - - diff --git a/docs/ref/template-response.txt b/docs/ref/template-response.txt index 3f5e772737..844b5fa46b 100644 --- a/docs/ref/template-response.txt +++ b/docs/ref/template-response.txt @@ -56,11 +56,11 @@ Attributes Methods ------- -.. method:: SimpleTemplateResponse.__init__(template, context=None, mimetype=None, status=None, content_type=None) +.. method:: SimpleTemplateResponse.__init__(template, context=None, content_type=None, status=None) Instantiates a :class:`~django.template.response.SimpleTemplateResponse` object - with the given template, context, MIME type and HTTP status. + with the given template, context, content type, and HTTP status. ``template`` The full name of a template, or a sequence of template names. @@ -75,12 +75,15 @@ Methods The HTTP Status code for the response. ``content_type`` - An alias for ``mimetype``. Historically, this parameter was only called - ``mimetype``, but since this is actually the value included in the HTTP - ``Content-Type`` header, it can also include the character set encoding, - which makes it more than just a MIME type specification. If ``mimetype`` - is specified (not ``None``), that value is used. Otherwise, - ``content_type`` is used. If neither is given, + + .. versionchanged:: 1.5 + + Historically, this parameter was only called ``mimetype`` (now + deprecated), but since this is actually the value included in the HTTP + ``Content-Type`` header, it can also include the character set + encoding, which makes it more than just a MIME type specification. If + ``mimetype`` is specified (not ``None``), that value is used. + Otherwise, ``content_type`` is used. If neither is given, :setting:`DEFAULT_CONTENT_TYPE` is used. @@ -144,7 +147,7 @@ TemplateResponse objects Methods ------- -.. method:: TemplateResponse.__init__(request, template, context=None, mimetype=None, status=None, content_type=None, current_app=None) +.. method:: TemplateResponse.__init__(request, template, context=None, content_type=None, status=None, current_app=None) Instantiates an ``TemplateResponse`` object with the given template, context, MIME type and HTTP status. @@ -165,12 +168,15 @@ Methods The HTTP Status code for the response. ``content_type`` - An alias for ``mimetype``. Historically, this parameter was only called - ``mimetype``, but since this is actually the value included in the HTTP - ``Content-Type`` header, it can also include the character set encoding, - which makes it more than just a MIME type specification. If ``mimetype`` - is specified (not ``None``), that value is used. Otherwise, - ``content_type`` is used. If neither is given, + + .. versionchanged:: 1.5 + + Historically, this parameter was only called ``mimetype`` (now + deprecated), but since this is actually the value included in the HTTP + ``Content-Type`` header, it can also include the character set + encoding, which makes it more than just a MIME type specification. If + ``mimetype`` is specified (not ``None``), that value is used. + Otherwise, ``content_type`` is used. If neither is given, :setting:`DEFAULT_CONTENT_TYPE` is used. ``current_app`` diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt index b1b4700b73..68860f123f 100644 --- a/docs/topics/http/shortcuts.txt +++ b/docs/topics/http/shortcuts.txt @@ -50,6 +50,9 @@ Optional arguments The MIME type to use for the resulting document. Defaults to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. + .. versionchanged:: 1.5 + This parameter used to be called ``mimetype``. + ``status`` The status code for the response. Defaults to ``200``. @@ -87,7 +90,7 @@ This example is equivalent to:: ``render_to_response`` ====================== -.. function:: render_to_response(template_name[, dictionary][, context_instance][, mimetype]) +.. function:: render_to_response(template_name[, dictionary][, context_instance][, content_type]) Renders a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. @@ -121,10 +124,14 @@ Optional arguments my_data_dictionary, context_instance=RequestContext(request)) -``mimetype`` +``content_type`` The MIME type to use for the resulting document. Defaults to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. + .. versionchanged:: 1.5 + This parameter used to be called ``mimetype``. + + Example ------- @@ -148,7 +155,7 @@ This example is equivalent to:: t = loader.get_template('myapp/template.html') c = Context({'foo': 'bar'}) return HttpResponse(t.render(c), - mimetype="application/xhtml+xml") + content_type="application/xhtml+xml") ``redirect`` ============ |
