0

i have a ModelForm that i use as the form_class for both of the views.

in both cases i need to update a different model before i save the object of

the views. i.e. i use the views to create/update model A and i need to update

model B based on the A object.

my problems are:

  1. in the model form i don't know if it create or update in the save method
  2. i don't know the old values of the fields in case of an update

anyone know how i can solve this?

update:

class updateA(UpdateView):
    model = A
    form_class = AForm

class createA(CreateView):
    model = A
    form_class = AForm

class AForm(ModelForm):
    a = super(AForm, self).save(commit=False)
    if commit:
        a.save()
    return log      
brad
  • 491
  • 1
  • 9
  • 24

0 Answers0