5👍
✅
Your error comes from this line:
vehiprepa = get_object_or_404(VehiPrepa,pk=object_id)
In your model form, you don’t have a object_id
.
To solve this problem, refer to the documentation; which states:
Also, a model form instance bound to a model object will contain a
self.instance attribute that gives model form methods access to that
specific model instance.
From that we understand that the bound instance is in self.instance
. So, in your model form you need
vehiprepa = self.instance
instead of the get_object_or_404
line.
Source:stackexchange.com