Changed admin views to output utf-8 charset explicitly

git-svn-id: http://code.djangoproject.com/svn/django/trunk@340 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-07-29 16:32:47 +00:00
parent 85d2b12bdf
commit 9e64035796
1 changed files with 8 additions and 7 deletions

View File

@ -48,7 +48,7 @@ def get_query_string(original_params, new_params={}, remove=[]):
def index(request): def index(request):
t = template_loader.get_template('index') t = template_loader.get_template('index')
c = Context(request, {'title': 'Site administration'}) c = Context(request, {'title': 'Site administration'})
return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
def change_list(request, app_label, module_name): def change_list(request, app_label, module_name):
from django.core import paginator 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), 'title': (is_popup and 'Select %s' % opts.verbose_name or 'Select %s to change' % opts.verbose_name),
'is_popup': is_popup, 'is_popup': is_popup,
}) })
return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
def _get_flattened_data(field, val): def _get_flattened_data(field, val):
""" """
@ -777,7 +777,8 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p
return HttpResponseRedirect(post_url_continue % new_object.id) return HttpResponseRedirect(post_url_continue % new_object.id)
if request.POST.has_key("_popup"): if request.POST.has_key("_popup"):
return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \ return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
(getattr(new_object, opts.pk.name), repr(new_object).replace('"', '\\"'))) (getattr(new_object, opts.pk.name), repr(new_object).replace('"', '\\"')),
mimetype='text/html; charset=utf-8')
elif request.POST.has_key("_addanother"): elif request.POST.has_key("_addanother"):
request.user.add_message("%s You may add another %s below." % (msg, opts.verbose_name)) request.user.add_message("%s You may add another %s below." % (msg, opts.verbose_name))
return HttpResponseRedirect(request.path) return HttpResponseRedirect(request.path)
@ -840,7 +841,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) raw_template = _get_template(opts, app_label, add=True, show_delete=show_delete, form_url=form_url)
# return HttpResponse(raw_template, mimetype='text/plain') # return HttpResponse(raw_template, mimetype='text/plain')
t = template_loader.get_template_from_string(raw_template) t = template_loader.get_template_from_string(raw_template)
return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
def change_stage(request, app_label, module_name, object_id): def change_stage(request, app_label, module_name, object_id):
mod, opts = _get_mod_opts(app_label, module_name) mod, opts = _get_mod_opts(app_label, module_name)
@ -956,7 +957,7 @@ def change_stage(request, app_label, module_name, object_id):
raw_template = _get_template(opts, app_label, change=True) raw_template = _get_template(opts, app_label, change=True)
# return HttpResponse(raw_template, mimetype='text/plain') # return HttpResponse(raw_template, mimetype='text/plain')
t = template_loader.get_template_from_string(raw_template) t = template_loader.get_template_from_string(raw_template)
return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
def _nest_help(obj, depth, val): def _nest_help(obj, depth, val):
current = obj current = obj
@ -1072,7 +1073,7 @@ def delete_stage(request, app_label, module_name, object_id):
"deleted_objects": deleted_objects, "deleted_objects": deleted_objects,
"perms_lacking": perms_needed, "perms_lacking": perms_needed,
}) })
return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')
def history(request, app_label, module_name, object_id): def history(request, app_label, module_name, object_id):
mod, opts = _get_mod_opts(app_label, module_name) mod, opts = _get_mod_opts(app_label, module_name)
@ -1090,4 +1091,4 @@ def history(request, app_label, module_name, object_id):
'module_name': meta.capfirst(opts.verbose_name_plural), 'module_name': meta.capfirst(opts.verbose_name_plural),
'object': obj, 'object': obj,
}) })
return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype='text/html; charset=utf-8')