2๐
-
This is for project (common) statics:
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
-
And this is for your apps statics:
STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )
Then in template you can access it using:
{% load static %}
{# this is in project static dir == tip โ1 == static/... #}
<script type="text/javascript" src="{% static ' js/bootstrap.min.js' %}"></script>
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" type="text/css">
{# suppose your app name is `questions` == tip โ2 == questions/static/questions/... #}
<script type="text/javascript" src="{% static 'questions/js/some.js' %}"></script>
<link href="{% static 'questions/css/pro.css' %}" rel="stylesheet" type="text/css">
๐คmadzohan
0๐
Try this :
<link href="{% static "css/pro.css" %} rel="stylesheet" type="text/css"/>
same applies for js.
You have given path for images as static "images/image_name.jpg"
but missing the same for css and js files
๐คAjay Gupta
0๐
I guess what you are missing is collectstatic
run this command
python manage.py collectstatic
docs : https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/
Hope this helps!
๐คYmartin
- [Answered ]-How do you have different settings per app in Django?
- [Answered ]-Custom registration redirect in django
- [Answered ]-Django virtual environment disaster
0๐
It was my problem too!
but i solve it :
- you should go to your project setting
setting.py
and findSTATIC_URL
- note url which is in
STATIC_URL
then change it to the path of absolute static files
for example my path isMySite/MyApp/static/My_App/'static files'
- after that copy the path of your
My_app
to theSTATIC_URL
then it should work.
Note: you should insert your path in STATIC_URL
with this format:
/file1/ or `/file1/file2/.../`
hope useful
๐คAli Najafi
- [Answered ]-Invalid literal for int() with base 10: 'n'
- [Answered ]-Custom Django Authentication
- [Answered ]-Page not found 404 with Django
- [Answered ]-Django Rest Framework nested serializer
Source:stackexchange.com