How to retrieve dynamically the data ,submitted by a form in an html page, in a python function pointing to another html page in views.py?

21 views
Skip to first unread message

Pierre Jutard

unread,
Jun 7, 2020, 4:09:53 PM6/7/20
to Django users

I have 2 html pages A and B. The user fills the AForm in the 'A' HTML page(URL: A) then he will go to the 'B' html page (url: A/B) but i would like to keep the AForm data of the 'A'HTML page in the python code in order to use it after in the python function pointing to the 'B' HTML page.


My idea was to retrieve the form data in parameter of the function pointing to the 'B' HTML page.


First:
I have tried to point the form data to the 'B' HTML page via this line in the 'A' HTML page code:
<form action="A/B" method="POST">

This is the function pointing to the A HTML page:

def A_HTML_Function_view(request):
    AForm = A_Form()
    if request.method == 'POST'
        AForm_result = A_Form(request.POST) 
BForm
        return render(request, 'AppName/B.html',{'Bform':Bform})
    else:
        AForm = A_Form()
    return render(request, 'AppName/A.html',{'AForm':AForm})

Agnese Camellini

unread,
Jun 8, 2020, 1:33:57 AM6/8/20
to django...@googlegroups.com
If you bind the form to a model and the you retrieve the model in the other page everything will be ok....

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b2d345a6-6d06-4577-a24c-f1233389220fo%40googlegroups.com.

Rupesh Dahal

unread,
Jun 8, 2020, 8:25:27 AM6/8/20
to Django users
You can save the data to a session but I would recommend you to store data in js in the browser itself.

Yamen Gamal Eldin

unread,
Jun 8, 2020, 2:30:52 PM6/8/20
to django...@googlegroups.com
You can have both forms in a formset and handle both of them in a single url, and you can handle your initial validations using HTML and javascript.

--
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...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages