Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #333 -- Added DEFAULT_MIME_TYPE setting, and set it to 'text/ht…

…ml; charset=utf-8' by default

git-svn-id: http://code.djangoproject.com/svn/django/trunk@670 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 36fc73a45bc857f0ed1c1a5c6f8e61017709e73e 1 parent 39a907a
Adrian Holovaty authored September 23, 2005
4  django/conf/global_settings.py
@@ -32,6 +32,10 @@
32 32
 # notifications and other various e-mails.
33 33
 MANAGERS = ADMINS
34 34
 
  35
+# Default MIME type to use for all HttpResponse objects, if a MIME type
  36
+# isn't manually specified. This is directly used as the Content-Type header.
  37
+DEFAULT_MIME_TYPE = 'text/html; charset=utf-8'
  38
+
35 39
 # E-mail address that error messages come from.
36 40
 SERVER_EMAIL = 'root@localhost'
37 41
 
3  django/utils/httpwrappers.py
@@ -2,8 +2,7 @@
2 2
 from pprint import pformat
3 3
 from urllib import urlencode
4 4
 import datastructures
5  
-
6  
-DEFAULT_MIME_TYPE = 'text/html'
  5
+from django.conf.settings import DEFAULT_MIME_TYPE
7 6
 
8 7
 class HttpRequest(object): # needs to be new-style class because subclasses define "property"s
9 8
     "A basic HTTP request"
14  django/views/admin/main.py
@@ -48,7 +48,7 @@ def get_query_string(original_params, new_params={}, remove=[]):
48 48
 def index(request):
49 49
     t = template_loader.get_template('index')
50 50
     c = Context(request, {'title': 'Site administration'})
51  
-    return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
  51
+    return HttpResponse(t.render(c))
52 52
 
53 53
 def change_list(request, app_label, module_name):
54 54
     from django.core import paginator
@@ -491,7 +491,7 @@ def change_list(request, app_label, module_name):
491 491
         'title': (is_popup and 'Select %s' % opts.verbose_name or 'Select %s to change' % opts.verbose_name),
492 492
         'is_popup': is_popup,
493 493
     })
494  
-    return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
  494
+    return HttpResponse(t.render(c))
495 495
 
496 496
 def _get_flattened_data(field, val):
497 497
     """
@@ -788,7 +788,7 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p
788 788
                 return HttpResponseRedirect(post_url_continue % pk_value)
789 789
             if request.POST.has_key("_popup"):
790 790
                 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
791  
-                    (pk_value, repr(new_object).replace('"', '\\"')), mimetype='text/html; charset=utf-8')
  791
+                    (pk_value, repr(new_object).replace('"', '\\"')))
792 792
             elif request.POST.has_key("_addanother"):
793 793
                 request.user.add_message("%s You may add another %s below." % (msg, opts.verbose_name))
794 794
                 return HttpResponseRedirect(request.path)
@@ -851,7 +851,7 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p
851 851
     raw_template = _get_template(opts, app_label, add=True, show_delete=show_delete, form_url=form_url)
852 852
 #     return HttpResponse(raw_template, mimetype='text/plain')
853 853
     t = template_loader.get_template_from_string(raw_template)
854  
-    return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
  854
+    return HttpResponse(t.render(c))
855 855
 
856 856
 def change_stage(request, app_label, module_name, object_id):
857 857
     mod, opts = _get_mod_opts(app_label, module_name)
@@ -976,7 +976,7 @@ def change_stage(request, app_label, module_name, object_id):
976 976
     raw_template = _get_template(opts, app_label, change=True)
977 977
 #     return HttpResponse(raw_template, mimetype='text/plain')
978 978
     t = template_loader.get_template_from_string(raw_template)
979  
-    return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
  979
+    return HttpResponse(t.render(c))
980 980
 
981 981
 def _nest_help(obj, depth, val):
982 982
     current = obj
@@ -1092,7 +1092,7 @@ def delete_stage(request, app_label, module_name, object_id):
1092 1092
         "deleted_objects": deleted_objects,
1093 1093
         "perms_lacking": perms_needed,
1094 1094
     })
1095  
-    return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
  1095
+    return HttpResponse(t.render(c))
1096 1096
 
1097 1097
 def history(request, app_label, module_name, object_id):
1098 1098
     mod, opts = _get_mod_opts(app_label, module_name)
@@ -1110,4 +1110,4 @@ def history(request, app_label, module_name, object_id):
1110 1110
         'module_name': capfirst(opts.verbose_name_plural),
1111 1111
         'object': obj,
1112 1112
     })
1113  
-    return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
  1113
+    return HttpResponse(t.render(c))

0 notes on commit 36fc73a

Please sign in to comment.
Something went wrong with that request. Please try again.