I need to get a variable from the settings in python:
SESSION_COOKIE_AGE = 4500
And use it in a javascript (js).
I found this: https://chriskief.com/2013/09/19/access-django-constants-from-settings-py-in-a-template/
But, is it the only way?
I imported requests:
import requests
and sent it to the template:
dictionary = {"session_cookie_age": SESSION_COOKIE_AGE}
return render(request, dictionary, "yourtemplate.html")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.