0

I tried deploying Django project to www.pythonanywhere.com, My website ran but could not load static files.

I did collectstatic command in hosting server console but got error.

my project file configuration as follows

myproject # parent directory
-DjangoApp1 # an app inside project
-Myproject main file(includes manage.py etc)
-DjangoApp2 # an app inside project
-DjangoApp3 (in this app my static files located `DjangoApp3/static/DjangoApp3` )

in settings.py file

STATIC_ROOT = os.path.join(BASE_DIR, "/static/")
STATICFILES_DIRS = ('/DjangoApp3/static/DjangoApp3/',)
STATIC_URL = '/static/'

when I run collectstatic method in local machine ,below error occured

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\DjangoApp3\\static'
3
  • Just asking do you have STATIC_URL? Commented May 16, 2020 at 19:58
  • yes I have STATIC_URL = '/static/' Commented May 16, 2020 at 19:59
  • I have posted an answer try and tell Commented May 16, 2020 at 20:02

2 Answers 2

2

This works

STATIC_ROOT = os.path.join(BASE_DIR, "/static/")
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'staticfiles'),)
STATIC_URL = '/static/'

I've covered the three in an answer here before

Sign up to request clarification or add additional context in comments.

1 Comment

Nice info on link.
1

Try this:

STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    (os.path.join(BASE_DIR, 'static')),
)

9 Comments

Thanks but sorry still same error occurred FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\djangorest\\insta\\blogproject\\static
take static folder one level up from DjangoApp3/
STATICFILES_DIRS should not be the same as STATIC_ROOT
change STATIC_ROOT = 'static' to STATIC_ROOT = 'staticfiles'
STATIC_URL should stay the same, STATICFILES_DIRS is something else covered here
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.