[Fixed]-How to insert app-level constants into a django template

1👍

You can easily expose your constants to view by just wrapping them in context.
so if you want to access NUM_IMAGES in view
first import it into views.py file

from models import NUM_IMAGES

then pass it to required view

def myview(request):
    #something to do
    return render( request,'app/page.html',{'NUM_IMAGES':NUM_IMAGES})

Leave a comment