Fixes deletion of formsets
This commit is contained in:
parent
5cb6d2dd5e
commit
0260e4c6d5
1 changed files with 8 additions and 12 deletions
|
@ -37,10 +37,10 @@ class EditView(UpdateView):
|
|||
self.object = self.get_object()
|
||||
form_class = self.get_form_class()
|
||||
form = self.get_form(form_class)
|
||||
phone_form = PhoneFormSet(queryset=Phone.objects.filter(profile=self.object))
|
||||
social_form = SocialFormSet()
|
||||
mail_form = MailFormSet()
|
||||
address_form = AddressFormSet()
|
||||
phone_form = PhoneFormSet(instance=self.object)
|
||||
social_form = SocialFormSet(instance=self.object)
|
||||
mail_form = MailFormSet(instance=self.object)
|
||||
address_form = AddressFormSet(instance=self.object)
|
||||
return self.render_to_response(
|
||||
self.get_context_data(form=form,
|
||||
phone_form=phone_form,
|
||||
|
@ -52,10 +52,10 @@ class EditView(UpdateView):
|
|||
self.object = self.get_object()
|
||||
form_class = self.get_form_class()
|
||||
form = self.get_form(form_class)
|
||||
phone_form = PhoneFormSet(self.request.POST)
|
||||
social_form = SocialFormSet(self.request.POST)
|
||||
mail_form = MailFormSet(self.request.POST)
|
||||
address_form = AddressFormSet(self.request.POST)
|
||||
phone_form = PhoneFormSet(self.request.POST, instance=self.object)
|
||||
social_form = SocialFormSet(self.request.POST, instance=self.object)
|
||||
mail_form = MailFormSet(self.request.POST, instance=self.object)
|
||||
address_form = AddressFormSet(self.request.POST, instance=self.object)
|
||||
if (form.is_valid() and phone_form.is_valid() and social_form.is_valid()
|
||||
and mail_form.is_valid() and address_form.is_valid()):
|
||||
return self.form_valid(form, phone_form, social_form, mail_form, address_form)
|
||||
|
@ -64,13 +64,9 @@ class EditView(UpdateView):
|
|||
|
||||
def form_valid(self, form, phone_form, social_form, mail_form, address_form):
|
||||
self.object = form.save()
|
||||
phone_form.instance = self.object
|
||||
phone_form.save()
|
||||
social_form.instance = self.object
|
||||
social_form.save()
|
||||
mail_form.instance = self.object
|
||||
mail_form.save()
|
||||
address_form.instance = self.object
|
||||
address_form.save()
|
||||
send_mail(
|
||||
"Fiche annuaire modifée",
|
||||
|
|
Loading…
Reference in a new issue