For Loop Populate ID In URL Django - django

I have a button on my template that says check progress, what the button does is takes you to another page for that user based on their user id.
/points/student_progress/1000 <-- id
What I'm trying to accomplish:
When my for loop runs to populate the student names on my template, i want it also to populate the student ID on the button as well. /points/student_progress/{{student_id}} . Here is my code. How do i add this in ?
Views.py
#login_required
def K8_Points_Classroom(request):
#context_from_k8_points = request.session['k8_points_context']
if request.method == 'POST':
form = K8Points_ClassroomForm(request.POST)
if form.is_valid():
form.save(commit=False)
form.save()
class_name = form.cleaned_data.get('class_name')
getstudents = Student.objects.filter(class_name = class_name)
students = getstudents.all()
form = K8Points_ClassroomForm()
context = {'form': form ,'students' : students, 'class_name': class_name,}
messages.success(request,("Points were successfully added for student !"))
return render(request, 'points/k8_points_classroom.html', context )
if not form.is_valid():
messages.warning(request,(form._errors))
class_name = request.POST.get('class_name')[0]
getstudents = Student.objects.filter(class_name = class_name)
students = getstudents.all()
context = {'form': form, 'students': students,}
return render(request, 'points/k8_points_classroom.html', context )
else:
form = K8Points_ClassroomForm()
return render(request, 'points/k8_points_classroom.html', context)
#login_required
def K8_Points(request):
if request.method == 'POST':
form = K8PointsForm(request.POST)
if form.is_valid():
form.save(commit=False)
class_name = form.cleaned_data.get('class_name')
getstudents = Student.objects.filter(class_name = class_name)
students = getstudents.all()
form = K8Points_ClassroomForm()
context = {'form': form ,'students' : students, 'class_name': class_name,}
# request.session['k8_points_context'] = context
return render(request,'points/k8_points_classroom.html', context)
else:
return HttpResponseBadRequest("Bad Request")
else:
form = K8PointsForm()
return render(request, 'points/k8_points.html', {'form': form} )
def Student_Progress(request, studentpsid):
studentid = Student.objects.get(studentpsid=studentpsid)
if K8Points.objects.filter(student_name=studentpsid).exists():
return render(request, 'points/student_progress.html', {'studentid': studentid} )
else:
return HttpResponseBadRequest("Student doesn't exist !")
HTML Template
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% crispy K8Points_ClassroomForm %}
{% load static %}
{% block content %}
<br>
<h2>{% load static %}
<img src="{% static 'forms/star.png' %}" alt="chain" height="62" width="62"> {{class_name}}</h2>
<br>
<br>
<script> </script>
<form action="/points/k8_points_classroom" method="POST">
{% csrf_token %}
<!-- Start Date -->
<div class="container">
<div class="container">
<div class='row'>
<div class="col-4">
<p> Recording Data as User : {{user.username}} </p>
</div>
</div>
<div class='row'>
<div class = "col-2">
<input type="button" onclick="window.location.href = '/points/k8_points';" value="Exit Classroom"/>
</div>
</div>
<br>
<div class='row'>
<div class = "col-2">
{{form.date|as_crispy_field }}
</div>
<div class = "col-2">
{{form.week_of|as_crispy_field }}
</div>
<div class = "col-2">
{{form.day|as_crispy_field }}
</div>
</div>
</div>
</form>
<div class="jumbotron" align="middle">
<img src="{% static 'forms/levelup.png' %}" alt="levelup" height="120" width= "120">
<h1>My Students</h1>
<!-- Line Break -->
<hr style="border: 1px solid black;"/>
<!-- Line Break -->
<div class="row mb-3">
{% for i in students%}
<div class="col-md-4 themed-grid-col"><h2>{{i.student_name}}</h2>
<p align="left"> Today's Score: {{total}}</p>
<h4>
<button type="button" class="btn btn-primary " data-toggle="modal"
data-target="#PointsBox{{student.pk}}"><i class="fas fa-level-up-alt"></i> Level Up
</button>
<i class="fas fa-chart-line"></i> Check Progress
</h4>
<div id="PointsBox{{student.pk}}" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<img src="{% static 'forms/star.png' %}" align="left" alt="chain" height="42"
width="42">
<h4 class="modal-title">Points Confirmation </h4>
<button type="button" class="close" data-dismiss="modal"> ×</button>
</div>
<div class="modal-body">
<h6>
<div class="modal-body">Please add the selected points for the current
student.</div>
</h6>
<form action="/points/k8_points_classroom" method="POST">
{% csrf_token %}
<div class="form-row" align='left'>
<div class="col-7">
{{form.class_name|as_crispy_field }}
{{form.student_name|as_crispy_field }}
{{form.time_frame|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="col-3" align='left'>
{{form.behavior|as_crispy_field }}
{{form.academic|as_crispy_field }}
<button type="submit" class="btn btn-success" ><i
class="fas fa-star"></i> Level Up
</button>
</div>
</div>
</div>
<div class="modal-foot"></div>
</div>
</div>
</div>
</div>
</form>
{% endfor %}
<script>
const class_name = "{{class_name}}";
var classnamedropdown = document.getElementById('id_class_name');
for (i = 0; i < classnamedropdown.options.length; i++) {
// if(classnamedropdown.options[i].text == "Mr. Neo 8th Grade Science")
if(classnamedropdown.options[i].text == class_name)
{
console.log(classnamedropdown.options[i].text)
$("#id_class_name").val(classnamedropdown.options[i].value)
}
}
</script>
{% endblock %}

Check Progress
Had to just add the {{i.studentpsid}} in the loop.

Related

Django CSRF token missing or incorrect but CSFR has been added

Django give me the following error CSRF token missing or incorrect. but I don't find the issue.
I have created my forms:
class ModCollaboratoriForm(forms.ModelForm):
class Meta:
model = AltriCosti
fields = "__all__"
and my simple views.py:
def collaboratori_commessa(request):
collaboratori_commessa=AltriCosti.objects.all()
if request.method == 'POST':
form = ModCollaboratoriForm(request.POST)
if form.is_valid():
print("Il form è valido")
new_input = form.save()
else :
form = ModCollaboratoriForm()
context={
'form':form,
'collaboratori_commessa': collaboratori_commessa,
}
return render(request, 'commesse/collaboratori_commessa.html', context)
And in my collaboratori_commessa.htm the following form:
<form id="contact-form" name="contact-form" method="post" >
{% csrf_token %}
<div class="card card-outline card-info shadow ">
<div class="card-header ">
<h4 class="mb-0">
<img src="{% static 'icon/plus-circle.svg' %}"> Informazioni generali
</h4>
</div>
<div class="card-body">
{{ form.media }}
<div class="row">
<div class="form-group col-2 0 mb-0" >
{{form.codice_commessa|as_crispy_field}}
</div>
.....
</div>
<div class="card-footer">
<div class="col-md-2">
<button class="btn btn-info form-control" type="submit" onclick="submitForm()">Registra</button>
</div>
</div>
</form>
Why django give me the CSRF Error?

Django - If i put 2 formsets together in my view, the function to add multiple times the same views doesnt work

I have this code bellow. Im using formset to add multiple times the same form. But if i put this 2 formsets together, like in my view, just the first data for each form is saved. And if i put just 1 formset in my def, it works, all datas for i put to the form is saved. Someone have any idea why this is happening? (sorry for my eng)
Forms.py
class InsereIdioma(forms.ModelForm):
class Meta:
model = Idioma
fields = '__all__'
exclude = ['usuario']
InsereIdiomaFormset = formset_factory(InsereIdioma, extra=1)
class InsereTecnologia(forms.ModelForm):
class Meta:
model = Tecnologia
fields = '__all__'
exclude = ['usuario']
InsereTecnologiaFormset = formset_factory(InsereTecnologia, extra=1)
Views.py
def cadastro_curriculo(request):
if request.method == 'GET':
formset_idioma = InsereIdiomaFormset(request.GET or None)
formset_tecnologia = InsereTecnologiaFormset(request.GET or None)
elif request.method == 'POST':
formset_idioma = InsereIdiomaFormset(request.POST)
formset_tecnologia = InsereTecnologiaFormset(request.POST)
if formset_idioma.is_valid():
for form in formset_idioma:
idioma = form.cleaned_data.get('idioma')
fluencia = form.cleaned_data.get('fluencia')
if idioma and fluencia:
Idioma(
idioma=idioma,
fluencia=fluencia,
usuario=request.user
).save()
if formset_tecnologia.is_valid():
for form in formset_tecnologia:
sistema = form.cleaned_data.get('sistema')
nivel = form.cleaned_data.get('nivel')
if sistema and nivel:
Tecnologia(
sistema=sistema,
nivel=nivel,
usuario=request.user
).save()
return render(request, "personal/curriculo.html", {
'formset_idioma': formset_idioma,
'formset_tecnologia': formset_tecnologia,})
template
<div class="card" style="margin-bottom: 25px;">
<div class="card-header" id="headingFour">
<h5 class="mb-0">Idiomas</h5>
</div>
{{ formset_idioma.management_form }}
<div class="content-inside" id="form_set_idioma">
{% for form in formset_idioma %}
{{form.non_field_errors}}
{{form.errors}}
<table class='no_error'>{{ form }}</table>
{% endfor %}
</div>
<input class="btn btn-primary fixedbutton" type="button" value="Adicionar" id="add_form_set_idioma">
<div id="empty_form_set_idioma" style="display:none">
<table class='no_error'>{{ formset_idioma.empty_form }}<br></table>
</div>
</div>
<div class="card" style="margin-bottom: 25px;">
<div class="card-header" id="headingFive">
<h5 class="mb-0">Tecnologia</h5>
</div>
{{ formset_tecnologia.management_form }}
<div class="content-inside" id="form_set_tecnologia">
{% for form in formset_tecnologia %}
{{form.non_field_errors}}
{{form.errors}}
<table class='no_error'>{{ form }}</table>
{% endfor %}
</div>
<input class="btn btn-primary fixedbutton" type="button" value="Adicionar" id="add_form_set_tecnologia">
<div id="empty_form_set_tecnologia" style="display:none">
<table class='no_error'>{{ formset_tecnologia.empty_form }}<br</table>
</div>
</div>
<script type='text/javascript'>
$('#add_form_set_idioma').click(function(){
var form_set_idioma_index = $('#id_form-TOTAL_FORMS').val(); $('#form_set_idioma').append($('#empty_form_set_idioma').html().replace(/__prefix__/g, form_set_idioma_index));
$('#id_form-TOTAL_FORMS').val(parseInt(form_set_idioma_index) + 1);});
$('#add_form_set_tecnologia').click(function(){
var form_set_tecnologia_index = $('#id_form-TOTAL_FORMS').val(); $('#form_set_tecnologia').append($('#empty_form_set_tecnologia').html().replace(/__prefix__/g, form_set_tecnologia_index));
$('#id_form-TOTAL_FORMS').val(parseInt(form_set_tecnologia_index) + 1);});
</script>
https://i.stack.imgur.com/vhjvX.png
Based on what #Daniel said, I've made some changes to your code and it's working just fine for me.
def cadastro_curriculo(request):
if request.method == 'GET':
formset_idioma = InsereIdiomaFormset(request.GET or None, prefix='idiomas')
formset_tecnologia = InsereTecnologiaFormset(request.GET or None, prefix='tecnologias')
elif request.method == 'POST':
formset_idioma = InsereIdiomaFormset(request.POST, prefix='idiomas')
formset_tecnologia = InsereTecnologiaFormset(request.POST, prefix='tecnologias')
if formset_idioma.is_valid():
for form in formset_idioma:
idioma = form.cleaned_data.get('idioma')
fluencia = form.cleaned_data.get('fluencia')
if idioma and fluencia:
Idioma(
idioma=idioma,
fluencia=fluencia,
usuario=request.user
).save()
if formset_tecnologia.is_valid():
for form in formset_tecnologia:
sistema = form.cleaned_data.get('sistema')
nivel = form.cleaned_data.get('nivel')
if sistema and nivel:
Tecnologia(
sistema=sistema,
nivel=nivel,
usuario=request.user
).save()
return render(request, "image_app/curriculo.html", {
'formset_idioma': formset_idioma,
'formset_tecnologia': formset_tecnologia})
template
<!DOCTYPE html>
<html lang="en">
<head>
<title>Student</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<form id="curriculo_form" method="post">
{% csrf_token %}
<button id="submitButton" class="btn btn-primary" type="submit">Salvar</button>
<div class="card" style="margin-bottom: 25px;">
<div class="card-header" id="headingFour">
<h5 class="mb-0">Idiomas</h5>
</div>
{{ formset_idioma.management_form }}
<div class="content-inside" id="form_set_idioma">
{% for form in formset_idioma %}
{{form.non_field_errors}}
{{form.errors}}
<table class='no_error'>{{ form }}</table>
{% endfor %}
</div>
<input class="btn btn-primary fixedbutton" type="button" value="Adicionar" id="add_form_set_idioma">
<div id="empty_form_set_idioma" style="display:none">
<table class='no_error'>{{ formset_idioma.empty_form }}<br></table>
</div>
</div>
<div class="card" style="margin-bottom: 25px;">
<div class="card-header" id="headingFive">
<h5 class="mb-0">Tecnologia</h5>
</div>
{{ formset_tecnologia.management_form }}
<div class="content-inside" id="form_set_tecnologia">
{% for form in formset_tecnologia %}
{{form.non_field_errors}}
{{form.errors}}
<table class='no_error'>{{ form }}</table>
{% endfor %}
</div>
<input class="btn btn-primary fixedbutton" type="button" value="Adicionar" id="add_form_set_tecnologia">
<div id="empty_form_set_tecnologia" style="display:none">
<table class='no_error'>{{ formset_tecnologia.empty_form }}<br</table>
</div>
</div>
</form>
</body>
</html>
JS
<script type='text/javascript'>
$('#add_form_set_idioma').click(function(){
var form_set_idioma_index = $('#id_idiomas-TOTAL_FORMS').val();
$('#form_set_idioma').append($('#empty_form_set_idioma').html().replace(/__prefix__/g, form_set_idioma_index));
$('#id_idiomas-TOTAL_FORMS').val(parseInt(form_set_idioma_index) + 1);});
$('#add_form_set_tecnologia').click(function(){
var form_set_tecnologia_index = $('#id_tecnologias-TOTAL_FORMS').val();
$('#form_set_tecnologia').append($('#empty_form_set_tecnologia').html().replace(/__prefix__/g, form_set_tecnologia_index));
$('#id_tecnologias-TOTAL_FORMS').val(parseInt(form_set_tecnologia_index) + 1);
});
</script>

Form Validation Not Displaying on Form

I have a custom form validation that runs on my popup window form. If the form validation occurs i get a bad request error which is what i have programmed in my views.py . How do i render it so the user stays on the form and the validation message displays. Thanks for the help. Here is my code.
#login_required
def K8_Points_Classroom(request):
#context_from_k8_points = request.session['k8_points_context']
if request.method == 'POST':
form = K8Points_ClassroomForm(request.POST)
if form.is_valid():
form.save(commit=False)
form.save()
class_name = form.cleaned_data.get('class_name')
getstudents = Student.objects.filter(class_name = class_name)
students = getstudents.all()
form = K8Points_ClassroomForm()
context = {'form': form ,'students' : students, 'class_name': class_name,}
return render(request,'points/k8_points_classroom.html', context)
else:
return HttpResponseBadRequest("Bad Request")
else:
return render(request, 'points/k8_points_classroom.html', {'form': form} )
Updated form.html
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% crispy K8Points_ClassroomForm %}
{% load static %}
{% block content %}
<br>
<h2>{% load static %}
<img src="{% static 'forms/star.png' %}" alt="chain" height="62" width="62"> {{class_name}}</h2>
<br>
<br>
<form action="/points/k8_points_classroom" method="POST">
{% csrf_token %}
<!-- Start Date -->
<div class="container">
<div class="container">
<div class='row'>
<div class="col-4">
<p> Recording Data as User : {{user.username}} </p>
</div>
</div>
<div class='row'>
<div class = "col-2">
{{form.date|as_crispy_field }}
</div>
<div class = "col-2">
{{form.week_of|as_crispy_field }}
</div>
<div class = "col-2">
{{form.day|as_crispy_field }}
</div>
</div>
</div>
</form>
<div class="jumbotron" align="middle">
<img src="{% static 'forms/levelup.png' %}" alt="levelup" height="120" width= "120">
<h1>My Students</h1>
<!-- Line Break -->
<hr style="border: 1px solid black;"/>
<!-- Line Break -->
<div class="row mb-3">
{% for i in students%}
<div class="col-md-4 themed-grid-col"><h2>{{i.student_name}}</h2>
<p align="left"> Today's Score: {{total}}</p>
<h4>
<button type="button" class="btn btn-primary btn-lg btn-block" data-toggle="modal"
data-target="#PointsBox{{ student.pk }}">Level Up
</button>
</h4>
<div id="PointsBox{{ student.pk }}" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<img src="{% static 'forms/star.png' %}" align="left" alt="chain" height="42"
width="42">
<h4 class="modal-title">Points Confirmation </h4>
<button type="button" class="close" data-dismiss="modal"> ×</button>
</div>
<div class="modal-body">
<h6>
<div class="modal-body">Please add the selected points for the current
student.</div>
</h6>
<form action="/points/k8_points_classroom" method="POST">
{% csrf_token %}
<div class="form-row" align='left'>
<div class="col-7">
{{form.class_name|as_crispy_field }}
<input type="student_name" class="form-control" value ="{{i}}" >
{{form.time_frame|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="col-3" align='left'>
{{form.behavior|as_crispy_field }}
{{form.academic|as_crispy_field }}
<button type="submit" class="btn btn-success" ><i
class="fas fa-star"></i> Level Up
</button>
</div>
</div>
</div>
<div class="modal-foot"></div>
</div>
</div>
</div>
</div>
</form>
{% endfor %}
{% endblock %}
You can't return a bad response if the form is invalid. Instead, render the page again with the invalid form and in the temolate you will be able to render the errors. Try starting rendering the form just using {{ form.as_p }} and you will see the errors. The form errors are in form.errors and each field has its own errors, you can access to them form.field.erorrs
if request.method == 'POST':
form = K8Points_ClassroomForm(request.POST)
if form.is_valid():
form.save(commit=False)
form.save()
class_name = form.cleaned_data.get('class_name')
getstudents = Student.objects.filter(class_name = class_name)
students = getstudents.all()
form = K8Points_ClassroomForm()
context = {'form': form ,'students' : students, 'class_name': class_name,}
return render(request,'points/k8_points_classroom.html', context)
return render(request, 'points/k8_points_classroom.html', {'form': form} )

My comment reply function is not working?

I am making a blog but I am stuck on a comment replies function. I don't know how to make a Reply function from which users can reply to the comments. I tried a lot but it's still displaying those comments like other comments not as replies to that specific comment.
Here,s the models.py
class Comment(models.Model):
post = models.ForeignKey(Post,on_delete=models.CASCADE,related_name = "comments")
name = models.CharField(max_length = 200)
body = models.TextField(default = True)
pub_date = models.DateTimeField(auto_now_add = True)
reply = models.ForeignKey('Comment',null = True,blank = True,on_delete=models.CASCADE)
class Meta:
ordering = ['-pub_date']
def __str__(self):
return self.name
#property
def get_replies(self):
return self.replies.all()
class Reply(models.Model):
post = models.ForeignKey(Comment,on_delete=models.CASCADE,related_name = "replies")
name = models.CharField(max_length = 200)
body = models.TextField(default = True)
Here's the views.py
def BlogDetail(request,pk):
post = get_object_or_404(Post,pk = pk)
comment = CommentForm(request.POST or None)
subscribe = Subscribe()
reply = ReplyForm(request.POST or None)
if request.method == 'POST':
subscribe = Subscribe(request.POST)
comment = CommentForm(request.POST)
reply = ReplyForm(request.POST)
if comment.is_valid():
comment.instance.post = post
comment.save()
elif subscribe.is_valid():
subscribe = subscribe.save(commit = True)
return redirect('index')
elif reply.is_valid():
reply.instance.com = com
reply = reply.save(commit = True)
return redirect('index')
return render(request,'app/blog.html',{'blog_object':post,'comment':comment,
'subscribe':subscribe,'reply':reply,
})
Here,s the blog.html
<form method='POST' action=".">
{%csrf_token%}
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4">
<div class="col-inner ts-20 m-sm">
<input type="submit" value="Subscribe to my daily letter" class="btn btn-primary subscribe">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-8">
<div class="ts-20">
<div class="form-group form-group-with-icon comment-form-email">
{{subscribe.email}}
</form>
<div class="form-control-border"></div>
</div>
</div>
</div>
</div>
<h3 style="color: #ff714a; font-weight:300;">
Leave a comment
</h3>
{% if request.user.is_authenticated %}
<div class="comments">
<div class="row">
<div class="container">
</div>
<form action="." method="post" id="commentform" class="comment-form">
{% csrf_token %}
<div class="col">
<div class="form-group form-group-with-icon comment-form-email">
{{comment}}
<div class="form-control-border"></div>
</div>
</div>
<div class="col">
<p class="form-submit">
<input name="submit" type="submit" id="submit" class="submit" value="Post Comment">
</p>
</div>
</form>
</div>
{% endif %}
<div class="post-comments">
<h3 style="color: #ff714a; font-weight:300;">See the latest comments</h3>
{% for comment in blog_object.get_comments %}
<div class="container">
<div class="row">
<div class="col comment_head">
<strong>{{comment.name}}</strong>
<div class="col comment_body">
<p>{{comment.body}}</p>
</div>
</div>
</div>
<div class="border"></div>
</div>
<form action="." method='POST'>
{% csrf_token %} {{reply}}
<input type="submit" value="submit">
</form>
{% endfor %} {% for reply in com.get_replies %}
<div class="container">
<div class="row">
<div class="col comment_head">
<strong>{{reply.name}}</strong>
<div class="col comment_body">
<p>{{reply.body}}</p>
</div>
</div>
</div>
<div class="border"></div>
<div class="reply">
</div>
</div>
</form>
{% endfor %}
</div>

Django Captcha Decorator

I've used a reCaptcha system created by the simpleisbetterthancomplex.com/ website.
In class-based views, it works perfectly fine, but whenever it comes to built-in libraries like:
from django.contrib.auth import views as auth_views
and functionalities:
auth_views.password_reset
it literally does not work as it should. The process of confirming the code of captcha is not executed at all.
I'm having a following usage of it:
url(r'^password/reset/$', check_recaptcha(auth_views.password_reset), name='password_reset'),
decorators.py:
def check_recaptcha(view_func):
#wraps(view_func)
def _wrapped_view(request, *args, **kwargs):
request.recaptcha_is_valid = None
if request.method == 'POST':
recaptcha_response = request.POST.get('g-recaptcha-response')
url = 'https://www.google.com/recaptcha/api/siteverify'
values = {
'secret': settings.GOOGLE_RECAPTCHA_SECRET_KEY,
'response': recaptcha_response
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
result = json.load(response)
if result['success']:
request.recaptcha_is_valid = True
else:
request.recaptcha_is_valid = False
messages.error(request, 'Invalid reCAPTCHA. Please try again.')
print(str('Invalid reCAPTCHA. Please try again.'))
return view_func(request, *args, **kwargs)
return _wrapped_view
password_reset_template.html
{% block content %}
<div class="row justify-content-center">
<div class="col-lg-4 col-md-4 col-sm-4">
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="row main">
<div class="main-login main-center">
<center>
<br>
<h3 class="card-title"><b>E-mail:</b></h3><br>
<form method="post" action=".">
{% csrf_token %}
{% for field in form %}
<div class="form-group" style="padding: 0px 40px;">
{% if field.errors %}
<div class="alert alert-danger">
{{ field.errors }}
</div>
{% endif %}
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope" aria-hidden="true"></i></span>
{{ field }}
</div>
</div>
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
{% endfor %}
<br>
<div style="padding: 0px 40px;">
<button type="submit" class="btn btn-primary btn-block">Reset Password</button>
</div>
<br>
<div class="g-recaptcha" data-sitekey="xxxxxx"></div>
<br>
</form>
</center>
</div>
<br>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
</div>
</div>
</div>
{% endblock %}