176👍
Try this,
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
Look at https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-STATIC_ROOT
10👍
You must have to give path in STATIC_ROOT in settings.py where all your static files are collected as for example:-
STATIC_ROOT = "app-root/repo/wsgi/static"
STATIC_URL = '/static/'
STATICFILES_DIRS = (
('assets', 'app-root/repo/wsgi/openshift/static'),
)
- [Django]-Django 1.8 KeyError: 'manager' on relationship
- [Django]-How can I find the union of two Django querysets?
- [Django]-How do I reference a Django settings variable in my models.py?
3👍
you can create ‘static’ folder in any subfolder and have required files in it.
In settings.py add the following lines of code:
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
STATIC_URL = '/static/'
After running
python manage.py collectstatic
a new static folder will be created in your parent App folder
- [Django]-How can I serialize a queryset from an unrelated model as a nested serializer?
- [Django]-How do I convert datetime.timedelta to minutes, hours in Python?
- [Django]-South migration: "database backend does not accept 0 as a value for AutoField" (mysql)
2👍
well had this error as well. I fixed:
STATIC_URL = '/static/'
if DEBUG:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
else:
STATIC_ROOT = os.path.join(BASE_DIR,'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
- [Django]-In a django model custom save() method, how should you identify a new object?
- [Django]-Disable a method in a ViewSet, django-rest-framework
- [Django]-How to deal with "SubfieldBase has been deprecated. Use Field.from_db_value instead."
- [Django]-Using Django auth UserAdmin for a custom user model
- [Django]-Get SQL query count during a Django shell session
- [Django]-Django Cache cache.set Not storing data
1👍
STATIC_ROOT = os.path.join(BASE_DIR, 'assest')
STATICFILES_DIR = [
os.path.join(BASE_DIR, 'static')
]
- [Django]-Django – how to unit test a post request using request.FILES
- [Django]-Good open source django project for learning
- [Django]-Allowing only super user login
0👍
STATIC_ROOT = "/var/www/YourSiteFolder/static/"
STATIC_URL = '/static/'
look at https://docs.djangoproject.com/en/1.11/howto/static-files/#deployment
- [Django]-Handle `post_save` signal in celery
- [Django]-Does SQLAlchemy have an equivalent of Django's get_or_create?
- [Django]-Getting the SQL from a Django QuerySet
0👍
- [Django]-How to Unit test with different settings in Django?
- [Django]-Django substr / substring in templates
- [Django]-"gettext()" vs "gettext_lazy()" in Django
0👍
if you want to load static files rather than admin panel files or getting errors while loading webpage static files like CSS js etc
I suggest you change the folder name of ‘static‘ to ‘staticfiles‘
and then add this code in your settings.py
STATICFILES_DIRS = (
os.path.join(BASE_DIR, ‘staticfiles’),
)
then after run python manage.py collectstatic
Then the problem will be fixed
- [Django]-How do I install an old version of Django on virtualenv?
- [Django]-Getting Values of QuerySet in Django
- [Django]-Django Rest Framework model serializer with out unique together validation