Last active
December 6, 2016 18:58
-
-
Save xtornasol512/1a2829856047bf6251cdc255a3ca4b34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#CaracteristicasPersonales | |
class Parte5View(View): | |
form_class=Parte5Form | |
initial='' | |
errores=[] | |
template_name = 'anexo8/parte5.html' | |
def get(self, request): | |
form = self.form_class(initial=self.initial) | |
return render(request, self.template_name, {'form': form}) | |
def post(self, request): | |
form = self.form_class(request.POST) | |
usuario=request.user | |
if form.is_valid(): | |
form=form.save() | |
form.usuario=usuario | |
form.save() | |
return HttpResponseRedirect("/anexo13/gracias/") | |
else: | |
self.errores.append(form.errors) | |
print ("No es valido el formulario") | |
print(self.errores) | |
return render(request, self.template_name, {'form': form}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base/base_anexo.html" %} | |
{% load staticfiles %} | |
{% block title %}Anexo 8 - Parte 5{% endblock title %} | |
{% block contenido %} | |
<section class="row"> | |
<div class="small-12 medium-8 medium-centered columns"> | |
<form class="" action="#" method="post">{% csrf_token %} | |
<div class="row"> | |
<h2 class="text-center">Caracteristicas Personales</h2> | |
{% for field in form %} | |
<div class="small-12 medium-6{% if forloop.last %} end {% endif %} columns"> | |
<div class="item"> | |
<label>{{ field.label_tag }} | |
{{ field }} | |
</label> | |
<span class="error">{{ field.errors }}</span> | |
{% if field.help_text %} | |
<p class="help">{{ field.help_text|safe }}</p> | |
{% endif %} | |
</div> | |
</div> | |
{% endfor %} | |
</div> | |
<input class="button success" type="submit" value="enviar datos"> | |
</form> | |
</div> | |
</section> | |
{% endblock contenido %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment