0

My project base directory is, then app and static dirs as below. I am trying to load CSS and JS. These does get rendered in the html but when I try to open the js css files directly in the browser for verification to see if the page is really addressed, it gives a page not found an error. What is missing here? How do I do this?

/data/projectname/ #BASE_DIR
/data/projectname/app/
/data/projectname/app/statics/
/data/projectname/app/statics/js/

Settings

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, '/app/statics/'),
)

View

<script type="text/javascript" src="/app/statics/js/css-doodle.min.js"></script>
    {% load static %}
<script type="text/javascript" href="{% static 'js/css-doodle.min.js' %}"></script>

HTML rendered, tried both ways

<script type="text/javascript" src="/app/statics/js/css-doodle.min.js"></script> 

renders home page instead of showing the actual js

<script type="text/javascript" href="/static/js/css-doodle.min.js"></script> 

404 page not found, it should show raw js file if it is truly properly included/addressed.debug output doesnt give any details

2
  • 1
    The path rendered should be in relation to the html file not the actual file system. Not clear what is your directory for html page, but you may remove the leading '/' in src attribute of the script element and try. In other words change /app/.. should to app/.. Commented Dec 22, 2019 at 2:49
  • @Gro Correct. that was it! a small thing. Can you put it as an answer, i will mark it. Commented Dec 22, 2019 at 2:56

1 Answer 1

1

The path rendered should be in relation to the html file not the actual file system. Not clear what is your directory for html page, but you may remove the leading '/' in src attribute of the script element and try. In other words change /app/.. should to app/..

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.