CodeMonkey
CodeMonkey

Reputation: 368

Django Templates accessing JS script

My template zone1map.htmlhas the dependency of matrix.js I am getting Error:[02/Feb/2016 13:09:07] "GET /v3app/zone1 HTTP/1.1" 200 10513 Not Found: /v3app/matrix.js . However matrix.js is located in V3/v3app, templates folder is in V3, My view code is:

def zone1(request):
    temp=controller.workDB()
    array=[]
    while temp:
        string = temp.pop()
        string1 = string.to_JSON()
        array.append(string1)
     fileDes=""
     return render_to_response('zone1map.html', {"JSON": json.dumps(array), "fileDes":fileDes})

call inside zone1map.html <script src="matrix.js"></script>

Upvotes: 0

Views: 44

Answers (1)

Thom Wiggers
Thom Wiggers

Reputation: 7052

You should serve the js as a static file from a separate folder. Django manages these files in a special way. This is documented here. An advantage of doing it this way, is it allows a 'dumb' webserver to serve these files on deployment.

Upvotes: 2

Related Questions