L
L
Larisa .•º2017-01-19 10:37:41
JavaScript
Larisa .•º, 2017-01-19 10:37:41

Is there a way to access variables in settings.py from jquery?

Tell me, how can I access the variables described in the settings.py of the project from jquery (javascript)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alk, 2017-01-19
@barolina

Certainly. Make a service in views.py that will be called using jquery and return json with the values ​​of the necessary variables from settings.py. Extract variable values ​​using python. You can google how to do this, for example, on request: django get variable from settings

M
Memorivardo, 2017-01-19
@Memorivardo

You can pull them out via AJAX or display these values ​​beforehand with python on the page in js variables (as you usually output HTML), and then read their values. But, of course, important configs (passwords and appearances) cannot be given away like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question