On Saturday, 4 March 2017 13:30:37 UTC, Tom Tanner wrote:
>
> In my `views.py`, I have one path render an html file:
>
> def interactive(request):
> if request.session.get('interactiveID') == None:
> t= get_template('blank-interactive.html')
> else:
> interactive_template= 'interactive-' + str(request.session['id']) +
> '/index.html'
> t= get_template(interactive_template)
>
> return HttpResponse(t.render())
>
> So `form.html` has an `<iframe>` that requests `/interactive`, and
> `request.session['id']` is set to `1`. When the iframe requests
> `/interactive`, it loads `interactive-1/index.html`. The iframe loads the
> HTML from that page, but cannot get the JS file at
> `interactive-1/scripts/main.js`.
>
> When I check the terminal, I see this 404 error: `GET
> /interactive/scripts/main.js`. If it would just load
> `/interactive-1/scripts/main.js`, there would be no problem. But Django
> loads `/interactive-1/index.html`, but not
> `/interactive-1/scripts/main.js`. Same goes for the CSS and image assets,
> which are in CSS and image folders.
>
> What do I need to change in Django for it to correctly load the JS, CSS,
> images and other assets?
>
There's not really enough information here to answer your question. How are
you referring to the assets in the template? Why do you have a different
path for those assets? Note though that template paths and asset paths have
nothing whatsoever to do with each other.
--
DR.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8176ee4a-9946-4c3a-80db-cab0d780e984%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.