Form Tools Summary page redirection

I am not able to post all the code however I will try my best to explain and hopefully someone will be able to assist!

I am using Django's formtools. I have four sections of a form, they are each their own (NamedUrlSessionWizardView, FormPreview) wizard. I am passing around the object id through session and DB retrieval as there is some logic around the object being deleted if the user goes back at a certain page.

Once a user has completed a section of the form they are shown a summary of the answers they have provided. Once they have submitted on the summary page this data gets written to the DB and the user is directed back to a tracker page showing them that the section is now completed. If the user were to click into the section that is completed I would need to show them the summary page again. This is all working as intended. However when the section has been completed and the user gets displayed the summary information if they hit submit again the user gets redirected to the start of that form section, where as i would like to direct them to the tracker page.

I'm unsure if this is a limitation of formtools or something wrong with my logic.

def done(self, form_list, **kwargs):
        object = object.objects.get(
            id=self.request.session["object"]
        )
        action = self.storage.extra_data.get("action")
        print("action:", action) #returns submit
        print("object.stageonecomplete:", object.stageonecomplete:) # returns True
        if object.stageonecomplete and action == "submit":
            print("in this loop that checks for stage one ") #prints
            object = self.add_fields(form_list, object)
            object.save()
            print("now redirecting!!") #prints
            self.storage.reset() 
            return HttpResponseRedirect(
                reverse(
                    "blah-blah-tracker",
                    kwargs={"object": object.id},
                )
            )

I've tried printing to ensure the condition is being met, I have tried clearing the storage just before redirecting as well.

Вернуться на верх