Sunday, July 30, 2017

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

Thanks for your reply, James. Appreciate it. BTW, if you check my template, the button is within the form tags, but you probably are right on the JS - I don't know JS much at all so just copied other people's code.

I may be mistaken, but I think the wizard link below requires a "static" or semi-static forms flow path (form1, form2, …, formlast). Generally, when you do pagination, there is no preset number of pages - it depends upon the data being requested or available. So, I think that option would not work. But, if I'm wrong, I'd love to know. Thanks.

And, as for using Java just so you can use Django, doesn't that raise the obvious question - so why use Django? 

To try to illustrate that my issue is a common business issue, here's a scenario that is exactly the same situation and one used by almost everyone:

A new car purchase site needs the user to pick the car and model. Then, that data stays static throughout the transaction. However, the user might want different options (tires, engines, transmission types, etc.). And, those options are always too many for one page, so they must be done using pagination. When all the options are reviewed - or maybe just one page of options or two or… - then the final idea is to show the user the car's price, have all the selections chosen listed out for the user to review, and ask for further actions like "do you want to purchase this car?". 

Are these types of business scenarios just not in Django's wheelhouse? 


On Jul 30, 2017, at 4:51 AM, James Schneider <jrschneider83@gmail.com> wrote:



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