Search code examples
pythondjangodjango-formsdjango-formwizard

create input form for 540 fields in django. Best approach?


I'm new to django and would like to hear your opinion on how to create a form for a table with 540 fields. What would be the best approach? Is it best to split the modelform into multiple components or create a template that collects the input in parts (multiple inputs per page) and proceeds through all fields? It would be great if you could point me to some information and/or examples. Thanks.


Solution

  • Django has a Form wizard that can store information accumulated across multiple pages, validating each step of the way.

    How it works

    Here’s the basic workflow for how a user would use a wizard:

    1. The user visits the first page of the wizard, fills in the form and submits it.
    2. The server validates the data. If it’s invalid, the form is displayed again, with error messages. If it’s valid, the server saves the current state of the wizard in the backend and redirects to the next step.
    3. Step 1 and 2 repeat, for every subsequent form in the wizard.
    4. Once the user has submitted all the forms and all the data has been validated, the wizard processes the data – saving it to the database, sending an email, or whatever the application needs to do.