Loading django/contrib/sitemaps/views.py +21 −5 Original line number Diff line number Diff line import warnings from django.contrib.sites.models import get_current_site from django.core import urlresolvers from django.core.paginator import EmptyPage, PageNotAnInteger Loading @@ -6,8 +8,15 @@ from django.template.response import TemplateResponse from django.utils import six def index(request, sitemaps, template_name='sitemap_index.xml', mimetype='application/xml', sitemap_url_name='django.contrib.sitemaps.views.sitemap'): template_name='sitemap_index.xml', content_type='application/xml', sitemap_url_name='django.contrib.sitemaps.views.sitemap', mimetype=None): if mimetype: warnings.warn("The mimetype keyword argument is deprecated, use " "content_type instead", DeprecationWarning, stacklevel=2) content_type = mimetype req_protocol = 'https' if request.is_secure() else 'http' req_site = get_current_site(request) Loading @@ -24,10 +33,17 @@ def index(request, sitemaps, sites.append('%s?p=%s' % (absolute_url, page)) return TemplateResponse(request, template_name, {'sitemaps': sites}, content_type=mimetype) content_type=content_type) def sitemap(request, sitemaps, section=None, template_name='sitemap.xml', mimetype='application/xml'): template_name='sitemap.xml', content_type='application/xml', mimetype=None): if mimetype: warnings.warn("The mimetype keyword argument is deprecated, use " "content_type instead", DeprecationWarning, stacklevel=2) content_type = mimetype req_protocol = 'https' if request.is_secure() else 'http' req_site = get_current_site(request) Loading @@ -51,4 +67,4 @@ def sitemap(request, sitemaps, section=None, except PageNotAnInteger: raise Http404("No page '%s'" % page) return TemplateResponse(request, template_name, {'urlset': urls}, content_type=mimetype) content_type=content_type) django/shortcuts/__init__.py +9 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ This module collects helper functions and classes that "span" multiple levels of MVC. In other words, these functions/classes introduce controlled coupling for convenience's sake. """ import warnings from django.template import loader, RequestContext from django.http import HttpResponse, Http404 Loading @@ -17,7 +18,14 @@ def render_to_response(*args, **kwargs): Returns a HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments. """ httpresponse_kwargs = {'content_type': kwargs.pop('mimetype', None)} httpresponse_kwargs = {'content_type': kwargs.pop('content_type', None)} mimetype = kwargs.pop('mimetype', None) if mimetype: warnings.warn("The mimetype keyword argument is deprecated, use " "content_type instead", DeprecationWarning, stacklevel=2) httpresponse_kwargs['content_type'] = mimetype return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) def render(request, *args, **kwargs): Loading docs/howto/outputting-csv.txt +3 −3 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading @@ -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: Loading docs/howto/outputting-pdf.txt +2 −2 Original line number Diff line number Diff line Loading @@ -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." Loading Loading @@ -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() Loading docs/internals/deprecation.txt +8 −2 Original line number Diff line number Diff line Loading @@ -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, Loading Loading
django/contrib/sitemaps/views.py +21 −5 Original line number Diff line number Diff line import warnings from django.contrib.sites.models import get_current_site from django.core import urlresolvers from django.core.paginator import EmptyPage, PageNotAnInteger Loading @@ -6,8 +8,15 @@ from django.template.response import TemplateResponse from django.utils import six def index(request, sitemaps, template_name='sitemap_index.xml', mimetype='application/xml', sitemap_url_name='django.contrib.sitemaps.views.sitemap'): template_name='sitemap_index.xml', content_type='application/xml', sitemap_url_name='django.contrib.sitemaps.views.sitemap', mimetype=None): if mimetype: warnings.warn("The mimetype keyword argument is deprecated, use " "content_type instead", DeprecationWarning, stacklevel=2) content_type = mimetype req_protocol = 'https' if request.is_secure() else 'http' req_site = get_current_site(request) Loading @@ -24,10 +33,17 @@ def index(request, sitemaps, sites.append('%s?p=%s' % (absolute_url, page)) return TemplateResponse(request, template_name, {'sitemaps': sites}, content_type=mimetype) content_type=content_type) def sitemap(request, sitemaps, section=None, template_name='sitemap.xml', mimetype='application/xml'): template_name='sitemap.xml', content_type='application/xml', mimetype=None): if mimetype: warnings.warn("The mimetype keyword argument is deprecated, use " "content_type instead", DeprecationWarning, stacklevel=2) content_type = mimetype req_protocol = 'https' if request.is_secure() else 'http' req_site = get_current_site(request) Loading @@ -51,4 +67,4 @@ def sitemap(request, sitemaps, section=None, except PageNotAnInteger: raise Http404("No page '%s'" % page) return TemplateResponse(request, template_name, {'urlset': urls}, content_type=mimetype) content_type=content_type)
django/shortcuts/__init__.py +9 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ This module collects helper functions and classes that "span" multiple levels of MVC. In other words, these functions/classes introduce controlled coupling for convenience's sake. """ import warnings from django.template import loader, RequestContext from django.http import HttpResponse, Http404 Loading @@ -17,7 +18,14 @@ def render_to_response(*args, **kwargs): Returns a HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments. """ httpresponse_kwargs = {'content_type': kwargs.pop('mimetype', None)} httpresponse_kwargs = {'content_type': kwargs.pop('content_type', None)} mimetype = kwargs.pop('mimetype', None) if mimetype: warnings.warn("The mimetype keyword argument is deprecated, use " "content_type instead", DeprecationWarning, stacklevel=2) httpresponse_kwargs['content_type'] = mimetype return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) def render(request, *args, **kwargs): Loading
docs/howto/outputting-csv.txt +3 −3 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading @@ -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: Loading
docs/howto/outputting-pdf.txt +2 −2 Original line number Diff line number Diff line Loading @@ -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." Loading Loading @@ -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() Loading
docs/internals/deprecation.txt +8 −2 Original line number Diff line number Diff line Loading @@ -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, Loading