diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index c958e38863..59edbcec70 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -32,6 +32,10 @@ LANGUAGE_CODE = 'en-us' # notifications and other various e-mails. MANAGERS = ADMINS +# Default MIME type to use for all HttpResponse objects, if a MIME type +# isn't manually specified. This is directly used as the Content-Type header. +DEFAULT_MIME_TYPE = 'text/html; charset=utf-8' + # E-mail address that error messages come from. SERVER_EMAIL = 'root@localhost' diff --git a/django/utils/httpwrappers.py b/django/utils/httpwrappers.py index 8b50688f66..f4a7c54f0c 100644 --- a/django/utils/httpwrappers.py +++ b/django/utils/httpwrappers.py @@ -2,8 +2,7 @@ from Cookie import SimpleCookie from pprint import pformat from urllib import urlencode import datastructures - -DEFAULT_MIME_TYPE = 'text/html' +from django.conf.settings import DEFAULT_MIME_TYPE class HttpRequest(object): # needs to be new-style class because subclasses define "property"s "A basic HTTP request" diff --git a/django/views/admin/main.py b/django/views/admin/main.py index 225920edea..a7e826d209 100644 --- a/django/views/admin/main.py +++ b/django/views/admin/main.py @@ -48,7 +48,7 @@ def get_query_string(original_params, new_params={}, remove=[]): def index(request): t = template_loader.get_template('index') c = Context(request, {'title': 'Site administration'}) - return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8') + return HttpResponse(t.render(c)) def change_list(request, app_label, module_name): from django.core import paginator @@ -491,7 +491,7 @@ def change_list(request, app_label, module_name): 'title': (is_popup and 'Select %s' % opts.verbose_name or 'Select %s to change' % opts.verbose_name), 'is_popup': is_popup, }) - return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8') + return HttpResponse(t.render(c)) def _get_flattened_data(field, val): """ @@ -788,7 +788,7 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p return HttpResponseRedirect(post_url_continue % pk_value) if request.POST.has_key("_popup"): return HttpResponse('' % \ - (pk_value, repr(new_object).replace('"', '\\"')), mimetype='text/html; charset=utf-8') + (pk_value, repr(new_object).replace('"', '\\"'))) elif request.POST.has_key("_addanother"): request.user.add_message("%s You may add another %s below." % (msg, opts.verbose_name)) return HttpResponseRedirect(request.path) @@ -851,7 +851,7 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p raw_template = _get_template(opts, app_label, add=True, show_delete=show_delete, form_url=form_url) # return HttpResponse(raw_template, mimetype='text/plain') t = template_loader.get_template_from_string(raw_template) - return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8') + return HttpResponse(t.render(c)) def change_stage(request, app_label, module_name, object_id): mod, opts = _get_mod_opts(app_label, module_name) @@ -976,7 +976,7 @@ def change_stage(request, app_label, module_name, object_id): raw_template = _get_template(opts, app_label, change=True) # return HttpResponse(raw_template, mimetype='text/plain') t = template_loader.get_template_from_string(raw_template) - return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8') + return HttpResponse(t.render(c)) def _nest_help(obj, depth, val): current = obj @@ -1092,7 +1092,7 @@ def delete_stage(request, app_label, module_name, object_id): "deleted_objects": deleted_objects, "perms_lacking": perms_needed, }) - return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8') + return HttpResponse(t.render(c)) def history(request, app_label, module_name, object_id): mod, opts = _get_mod_opts(app_label, module_name) @@ -1110,4 +1110,4 @@ def history(request, app_label, module_name, object_id): 'module_name': capfirst(opts.verbose_name_plural), 'object': obj, }) - return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8') + return HttpResponse(t.render(c))