[Answered ]-Editing model with form.py

1👍

The car can be passed to the ModelForm instance as the instance keyword argument, ie.

AddCar(instance=car)

To detect changes, you could use the is_valid() method of the AddCar instance combined with cleaned_data dictionary. You would have to fetch the car object as already you are, instantiate the AddCar form with request.POST values, and then compare values between the car you’ve fetched and AddCar.cleaned_data.

1👍

form = AddCar({'car': get_object_or_404(Car, pk=car_id,).name,})

Without ModelForm

👤Leon

Leave a comment