jazzband / django-formtools

A set of high-level abstractions for Django forms
https://django-formtools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
784 stars 135 forks source link

Question: Best way to make request after form submission #231

Closed mschoettle closed 1 year ago

mschoettle commented 1 year ago

We have a multi-step form where we collect data in each step. And in some steps, there needs to be a request to an external service or a DB lookup to find data. It can be generalized as:

  1. the user provides some information in the first part of the form and hits "search"
  2. if the form is valid, make a request or lookup
  3. present the result to the user
  4. the user confirms the data/adds more data and continues to the next step

An example would be providing a name and email to search for a customer, then confirming the accuracy of the found information and continuing to the next step.

I have not yet figured out a clean way to hook into the form wizard to make such an additional request. Is there? Or is this a use case where it's better not to use a form wizard (we use it because it handles the step navigation and data storage)?

claudep commented 1 year ago

I don't think this needs any special treatment, the request/lookup could be done as somewhere in a form-specific method.

Closing as this is not an issue, I'd suggest to ask on Django forums.