Mustapha Aoussar
Mustapha Aoussar

Reputation: 5923

WindowsError: [Error 267] The directory name is invalid

PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
STATICFILES_DIRS = (
    os.path.join(PROJECT_PATH, 'static'),
)

This code returns the following error message:

WindowsError: [Error 267] The directory name is invalid

I do not understand what's wrong in this code. I tried to remove the comma but I get another error: Your STATICFILES_DIRS setting is not a tuple or list; perhaps you forgot a trailing comma?

Also when I insert a static path I get that error:

STATICFILES_DIRS = (
    'F:/DEV/apps/myproject/static/',
)

And when I remove the path from STATICFILES_DIRS I don't get any error and the site works fine:

STATICFILES_DIRS = () #no error

Any help is appreciated! Thank you!

Upvotes: 1

Views: 11347

Answers (1)

xyres
xyres

Reputation: 21734

Instead of using abspath in your PROJECT_PATH, use dirname.

PROJECT_PATH = os.path.dirname(os.path.dirname(__file__))

Upvotes: 1

Related Questions