Reputation: 879
I'm trying to add some static files to my project. I have tried adding a static folder to my app.
I have two apps:
I have a lot of CSS/js content and I don't really know which is the best method to save the files, maybe all static files should be in one directory 'staticfiles' or each app should have 'static' folder. I have tried adding static folder to one of my apps, at this time - authn
. And by trying to load the static files I firstly did python manage.py collectstatic
, that put my all files into one folder, but I got two different folders now - admin, main. After tried putting all my static files into a static folder in authn
app, but the static files were not loading after that. Here are my project structure and some photos and logs of the console, pycharm.
Upvotes: 0
Views: 606
Reputation: 135
static
folder outside the appstatic
create two folder main
and auth
main
and auth
create css
js
img
and another catagories of folderPut each app's static file into their folder.That is put main
app's css into static/main/css/main.css
like that
In settings.py
make some changes-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ]
Upvotes: 1
Reputation: 455
You need to add authn's static to STATICFILES_DIRS. Detail
STATICFILES_DIRS=[
os.path.join(PROJECT_PATH, 'static'),
os.path.join(PROJECT_PATH, 'authn', 'static')
]
Upvotes: 1