0

My problem is that I am using Django STATIC_URL within my java script code. My code works in my developing environment but when I upload it to pythonanywhere.com it's not working. I checked my code relative paths it's working but using STATIC_URL it's not working my code looks like this:

document.write("  <source data-src='{{STATIC_URL}}{{filename}}' type='video/mp4' >");
2
  • 1
    Is that in a .js file or is it javascript code written inside <script> tags in the html file? Commented Oct 23, 2015 at 21:38
  • its java script code written in <script> tags Commented Oct 23, 2015 at 21:46

1 Answer 1

3

You should be using something like the following Import staticfiles in your template:

{% load staticfiles %}

Then to access the static dir use 'static':

<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>

That will point to the static dir you have on the file system and the subdirectory 'my_app'.

So you would have:

document.write("  <source data-src='{% static "filename" %}' type='video/mp4' >");

Check out https://docs.djangoproject.com/en/1.8/howto/static-files/.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.