That is definitely much more clear.

The usual way of doing this is to handle it like a shopping cart (plenty of
examples only a google search away).
Typically you store this information in the user's session in the first
view, then retrieve it in the subsequent view(s).

Note that `request.is_ajax` is deprecated and does not even exist anymore
in Django 3.x. You can guess that from other info, but you should probably
use a
different view for handling the ajax request in any case, for clarity and
maintainability. The response data would usually use a different format
(json vs text/html).

Regards, David

On Wed, Dec 1, 2021 at 6:04 AM kayhan <kayhank...@gmail.com> wrote:

> Sorry I did not ask the question well.
> Question:
> How to first send some data with an Ajax request to Django view and then
> with a post request, send the form information to the same view and use the
> data sent in the previous request (Ajax request) in the second request ?
>
> def planing(request):
>
>     if request.is_ajax():
>         # Get user location from user location.js file:
>         latitude = request.POST.get('latitude', None)
>         longitude = request.POST.get('longitude', None)
>
>
>     elif request.method == "GET":
>         return render(request, "tourist/planing.html")
>
>
>     elif request.method == "POST":
> # Here I want to take the form data and have
> #the previous request data (latitude, longitude) here and do a series of
> processing.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE5VhgWbiA8Ayhkss1saVg9my_S%2Bw8e1SYxhwp3xGCTD2L8snA%40mail.gmail.com.

Reply via email to