Majoris
Majoris

Reputation: 3189

Django include static CSS JS files - path included but not read

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

Upvotes: 0

Views: 34

Answers (1)

Gro
Gro

Reputation: 1683

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/..

Upvotes: 1

Related Questions