Hello all -
I am new to Django. I have created CBVs for updating a formset i have created between a parent Project to a child Position models. A Project can have multiple Position(s) via ForeignKey. I have been able to create the CreateView with much success, however the UpdateView is not working at all. When I hit the save button in my HTML page, the webpage refreshes and nothing happens. No errors, no redirect, or any signal to what is keeping it from saving and going to the success url. If you check the django admin the save did not POST at all. Normally I have an error code to go off of but unfortunately nothing. Maybe along with the direct solution with this issue, for future problems like these how do i debug and solve on my own? I want to be a self-thinker. My project is on GitHub in the link below.
Hello all -
Thank you very much for posting your code - that will make it easier to help diagnose this issue.
Can you please also specify which view is not working, and in which file that view resides?
The view I am having issues with is the “ProjectEdit” view located in the projects app. It is connected to the project_edit.html file in the templates folder. Thanks for the fast response Ken!
Unless I’m missing something, you’re not assigning the parent class to the instances of the formset forms:
if formset.is_valid(): response = super().form_valid(form) formset.instance = self.object formset.save()
What I interpret from the docs in the second paragraph in the section Overriding clean() on a ModelFormSet is that you need to iterate over the forms to set the parent object in each form individually. (Take a look at the second example in that section.)