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(