0๐
โ
I fixed this issue by using RequestContext
instead of Context
:
def login(request):
if request.method == "POST":
return render(request, 'login.tpl')
elif request.method == "GET":
# Prepare templates
header = get_template("header.tpl")
body = get_template("login.tpl")
footer = get_template("footer.tpl")
html = header.render(RequestContext(request, {"title": "Login", "charset": "UTF-8"}))
html = html + body.render(RequestContext(request, {}))
html = html + footer.render(Context({}))
return HttpResponse(html)
๐คuser1529891
1๐
You are missing the return
. The view is a function and expects you to return an HTTPResponse
object.
render_to_response('list.tpl', context_instance=RequestContext(request))
should be
return render_to_response('list.tpl', context_instance=RequestContext(request))
Another thing,
if request.POST
should be
if request.method == 'POST'
Moreover, Avoid using render_to_response
. Instead, use render
. Source
return render(request, 'list.tpl')
๐คRod Xavier
- [Answer]-Django-storages + django-pipeline + gzip
- [Answer]-Error installing Python Django using pip on Windows 8
- [Answer]-How to output django_filters.RangeFilter text boxes inline?
Source:stackexchange.com