0

I have these directories:

└── MY_FOLDER
    ├── MY_PROJECT
    │   └── settings.py
    │      
    ├── MY_APP
    ├── STATIC
    │   └── style.css
    ├── MEDIA
    └── manage.py

In the settings.py I've indicated:

BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_URL = 'static/'
STATICFILES_DIR = (os.path.join(BASE_DIR,'static'))

When I

print(STATICFILES_DIR)

I get a path: MY_FOLDER/STATIC - what is exactly I wanted.

But Django don't see any css there, in that folder.

I tried to put my css to MY_APP/STATIC and it started to work correctly. But I want to have it not in MY_APP but in BASE_DIR/STATIC. How to do it?

Or if it is impossible, how to make a correct path for STATICFILES_DIR to let it search my statics in all apps I'll add in the future. Not only in one app by doing this:

STATICFILES_DIR = (os.path.join(BASE_DIR,'MY_APP','static'))

Thanks.

2 Answers2

0

Always look for the documentation, you are naming the directive wrong and it also should be a list.

STATICFILES_DIRS = [
    BASE_DIR / "static",
]
Niko
  • 3,012
  • 2
  • 8
  • 14
  • Got it, thank you for your answer. As I've understood the gist is that you always have to put your static folder into an app by default. And only if you want to change this, you have to add STATICFILES_DIRS and better with prefixes, otherwise you even don't need it. Thank you Niko! The documentation has helped! I will read it more often. – this_is_a_person Dec 01 '22 at 05:43
0

Try this:

STATIC_URL = '/static/'

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

Note: your static folder must be lowercase and ensure that static folder must be inside project root not inside an app

Manoj Tolagekar
  • 1,816
  • 2
  • 5
  • 22