-1

I'm new to Django and HTML.
i have a code like below:

...
<script>
  var cars = ["Saab", "Volvo", "BMW"];
</script>
...

I need to pass the var (["Saab", "Volvo", "BMW"]) to my Django view.

Azametzin
  • 5,223
  • 12
  • 28
  • 46

1 Answers1

0

You can do this with AJAX, send the data via POST and then in the Django view you can access it with request.POST.

You can use this as a reference:

https://simpleisbetterthancomplex.com/tutorial/2016/08/29/how-to-work-with-ajax-request-with-django.html How do I POST with jQuery/Ajax in Django?

Dean Elliott
  • 1,245
  • 1
  • 8
  • 12