I am trying to pass multiple variables in Django render. One of them is the csrf token and the other one is my form (because I need the errors from the form) For some reason none of them work. Any help?
Here is the template :
<form class = "navbar-form" action="{% url "registry.views.register" %}" onsubmit=" return ClickButton(); " method= "POST" >
{% csrf_token %}
{{ form.errors}} {{ form.non_field_errors }}
here is the view.py:
def register(request):
form_save = RegisterationForm()
if request.method == 'POST':
form = RegisterationForm(request.POST)
if form.is_valid():
user_info={}
user_info['username'] = form.cleaned_data['username']
user_info['password'] = form.cleaned_data['password']
form.save(user_info)
return render_to_response('register_success.html',user_info)
else:
form_save = form
return render_to_response('register.html',{'csrf':csrf(request),'locals':locals()})