Sunday, July 30, 2017

Re: Django form needs pagination and saved data - how????



On Jul 28, 2017 5:56 PM, "Jim Illback" <subaru_87@hotmail.com> wrote:
I use the latest versions of Django, python, bootstrap3, and crispy forms for this project.

I am trying to present a list of flashcards to a user, sorted by category (e.g., Math, Vocabulary, etc.). Then, I want the user to check either the full category or individual flashcards to be added to their practice account. 

To maintain user inputted checkboxes on multiple pages, I must use POST. But, pagination only uses GET. So, a hack on pagination is to wrap the Next/Previous buttons in a sub-form and POST using the buttons. This works for pagination, but then my normal "I'm done, submit this session and process the updates" button - my submit button - does nothing: no GET, no POST, nothing. 

How can I enable pagination, multiple screen data accumulation across pages, and final submission of the session when complete? 

I can't speak to your submit button issue, other than either a piece of JavaScript is getting in the way, or the button is located outside of a <form> tag.

As for the rest of your troubles, it really sounds like you need a form wizard framework, which is what I think you mean by "pagination". Django used to ship one as part of the contrib package, but has since moved it out to it's own separately maintained app.


It handles keeping data state across multiple form submissions, along with dynamic form additions/omissions based on previous steps.

Another option you may consider is developing this process like a single-page-application, where all of the data and forms are managed via JS, and the final collection of data is submitted as a single blob to the server for permanent storage. That's obviously over simplified, but I hope you catch my meaning.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVCh5oEr3rHLEUB4L%3Dpus_bL8H%2BxpmCev5syjes_XOBDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment