css - I can't seem to get my static files to load using Django -
i can't seem life of me static files work... i've been reading documentation here:
https://docs.djangoproject.com/en/1.8/ref/settings/#static-root
and i've come conclusion need following settings
static_root static_url staticfiles_dir
i believe static_root
if want use ./manage.py collectstatic
, have them in 1 folder deployment, don't need that
currently static_url
static_url = '/static/'
and i'm not sure staticfiles_dirs
should set to. i've literally tried every single combination can think of.
staticfiles_dirs = ( "e:\pyprojects\elsablog\static" )
i have hardcoded , still doesn't work!
elsablog blog static blog elsablog static***
i'd put files static*** folder not static folder in blog app. (my bootstrap, js, css, want able access globally)
here index.html
{% extends "base.html" %} {% block content %} <script src=/static/js/test.js"% ></script> <ul> {% topic in topic_list %} <li>{{ topic.topic_text}}</li> <ul> {% subtopic in subtopic_list %} {% if subtopic.topic.topic_text == topic.topic_text%} <li>{{ subtopic.subtopic_text}}</a></li> {% endif %} <ul> {% question in question_list %} {% if question.topic.topic_text == topic.topic_text , question.subtopic.subtopic_text == subtopic.subtopic_text%} <li><a href="/blog/{{ question.id }}/">{{ question.question_text }}</a></li> {% endif %} {% endfor %} </ul> {% endfor %} </ul> {% endfor %} </ul> <a href="javascript:a_message()">click eea message..</a> {% endblock content %}
and base.html
<!doctype html> {% load staticfiles %} <html lang="en"> <head> <meta charset="utf-8"> <title>esla's blog</title> <link rel="stylesheet" href="{% static "css/prism.css" %}"> <script src="{% static "js/prism.js" %}"></script> <script src=/static/js/test.js"% ></script> </head> <body> {% block content %} {% endblock %} <a href="javascript:a_message()">click message..</a> </body> </html>
i'd appreciate help, guys~!
from django docs re: staticfiles_dirs:
this setting defines additional locations staticfiles app traverse if filesystemfinder finder enabled, e.g. if use collectstatic or findstatic management command or use static file serving view.
the default find files stored in staticfiles_dirs setting (using django.contrib.staticfiles.finders.filesystemfinder) , in static subdirectory of each app (using django.contrib.staticfiles.finders.appdirectoriesfinder).
either way, try 1 in settings file instead of current setting:
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) staticfiles_dirs = ( os.path.join(project_root, 'static'), )
Comments
Post a Comment