2
Add django.contrib.staticfiles
to INSTALLED_APPS
in your settings.py
.
Remove STATICFILES_FINDERS
, STATICFILES_DIRS
, STATIC_ROOT
from your settings.py
.
change your base.html
to something like this:
{% load staticfiles %}
<!DOCTYPE html>
<html lang="fa">
<head>
<script type="text/javascript" src="{% static 'my_app/js/app.js' %}"></script>
<title>{{ title }}</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
0
I had faced the same issue which got solved after the following changes.
In HTML pages:
{% load static %} ## loads the static folder and images inside it.
<div id='button-holder'><img src="{% static "glass.png" %}" alt="Hi!" /></div> ## for images
src="{% static 'my_app/js/app.js' %} ## for scripts.
In urls.py
urlpatterns = patterns('',...
........
)+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
After this run command as @Daniel Roseman have mentioned python manage.py collectstatic
. The findstatic
command can help show you which files are found.
Example
python manage.py findstatic css/base.css admin/js/core.js
You can find help here regarding it.
- [Answer]-Django modelform.is_valid() no results, no errors, nothing
- [Answer]-Django forms: MultipleChoiceField Error too many values to unpack
- [Answer]-Django REST framework – What is the correct way of registering / validating new users?
- [Answer]-Filter a model in using "for" in Django
- [Answer]-Heroku django collectstatic error
-1
You are supposed to run manage.py collectstatic
to copy your app-level static files to the central static directory.
Source:stackexchange.com