Submitting a user to a page created based on their POST request in Django

I have a form in which the user selects several items to display on the "next page". This selection is always unique, and we will store each set of selections made using a model indexed using id, as is the case with Django models. When the user selects his choice and POSTusing the submit button, I would like our application to save its selection in the model, and then display the page with the model identifier, so that the user can return to the page it was created at any time with a simple request GET.

For example, the user navigates to /coolapp/selectprefs/, makes several selections, and clicks the submit button. Then the user should be delivered to /coolapp/selections/42, given that when the user sent and created the record, the record was assigned id 42.

I don’t understand how to send the user to the “next page” as an answer (for example, /coolapp/selections/42in the above example) after clicking the submit button. Taking a user to a unique identifier page based on what she entered seems like a common task (for example, this will happen when I click the button to send this question to the CO), but I'm not sure how to do it, and would appreciate your advice.

+3
source share
1
+8

Source: https://habr.com/ru/post/1707264/


All Articles