from django.utils.simplejson import dumps, loads
# -*- coding: utf-8 -*-
def index(request):
return render_to_response('test2/index.html')
def add_lang(request):
logging.debug("Got request")
a = request.POST
logging.debug(a["lang"])
lang=dumps(a["lang"])
l = Language(code=lang)
l.save()
lang=loads(lang)
logging.debug(loads(l.code))
return render_to_response('test2/test21.html', context_instance=RequestContext(request,{'test2开发者_如何学C': l.code}))
My question is there any way to load the variable back to its original format in the template file.i.e, i want a function similar to loads in template.I do not want to do it in views since there will be a lot of code changes
test21.html
{{ test2 }}
//The above prints"\u0905\u0902\u0917\u094d\u0930\u0947\u091c\u093c\u0940, \u0939\u093f\u0902\u0926"
Not without writing a custom filter.
精彩评论