Pass dict from django to JS

Global context from Django to frontend Django:

import json 
from django.conf import settings 

def backend_context(request): 
   return { 
    'backend_context': json.dumps({ }) 
   }

You can add backend_context to your contextprocessors in settings.py (for append it in every request context) or simply add to response rendering arguments.

#django #javascript
0
Ivan Borshchov profile picture
Oct 31, 2016
by Ivan Borshchov
Did it help you?
Yes !
No

Best related