From b3bd9530d5c17391a66cb6cb842716686d8faa62 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 16 Dec 2015 10:58:19 -0200 Subject: [PATCH] Fix save parlamentar --- parlamentares/views.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/parlamentares/views.py b/parlamentares/views.py index 5c97e0456..e4578cf20 100644 --- a/parlamentares/views.py +++ b/parlamentares/views.py @@ -1,5 +1,5 @@ from re import sub - +from datetime import date from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, ButtonHolder, Fieldset, Layout, Submit from django import forms @@ -326,13 +326,12 @@ class ParlamentaresCadastroView(FormMixin, GenericView): parlamentar.biografia = sub(' ', ' ', strip_tags(form.data['biografia'])) - parlamentar.save() - - mandato = Mandato() + parlamentar.save() - mandato.parlamentar = parlamentar - mandato.legislatura = Legislatura.objects.get(id=pk) - mandato.save() + mandato = Mandato() + mandato.parlamentar = parlamentar + mandato.legislatura = Legislatura.objects.get(id=pk) + mandato.save() return self.form_valid(form) else: return self.render_to_response(