Django settings.py variables in templates

前端 未结 1 1892
名媛妹妹
名媛妹妹 2021-01-05 09:37

I\'m encountering a very strange error. I have an app ID defined in my settings.py file like so:

CARDSPRING_APP_ID = \'################\'


        
相关标签:
1条回答
  • 2021-01-05 10:36

    Create a file called context_processors.py and write the following context processor:

    from django.conf import settings
    
    def cardspring(request):
        return { 'CARDSPRING_APP_ID': settings.CARDSPRING_APP_ID }
    

    Then add your.location.context_processors.cardspring to TEMPLATE_CONTEXT_PROCESSORS in your Django settings file, where your.location is the location of your context_processors.py file.

    0 讨论(0)
提交回复
热议问题