-1

I did run the python manage.py collectstatic code, and after that all the static files were collected in the static folder. but the static files needed for the syling of the admin panel are not working. Could you help?

settings.py

STATIC_URL = 'static/'

STATICFILES_DIRS = [
    'Portfolio/static/',
    'Portfolio/',
    ''
]

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

The static folder created after running

The static files inside the static folder

Ivan Starostin
  • 8,798
  • 5
  • 21
  • 39
  • Please elaborate what is "not working". Try opening any of non-working static file URL and add response status, error message to your question. Also show your urls.py. And clarify is debug=true or false. – Ivan Starostin Apr 02 '22 at 17:09
  • Have you seen this [issue](https://stackoverflow.com/questions/4420378/why-does-my-django-admin-site-not-have-styles-css-loading)? – Javad Apr 02 '22 at 17:15

1 Answers1

0
  1. Comment out the STATIC_ROOT

  2. I think your STATICFILES_DIRS is wrong change it to os.path.join(BASE_DIR, 'static')

  3. Try to change STATIC_URL. for example: /Portfolio-Deployment-Folder/static/

  4. Try to change localhost port for example:

    python3 manage.py runserver 9000 or 7000
    

    most probably problem of STATICFILES_DIRS

And finally a full example for STATIC in my personal project:

STATIC_URL = '/myproject/static/'
# STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_DIRS = [
    BASE_DIR / 'static'
]
Zoe
  • 27,060
  • 21
  • 118
  • 148