0

So I upload my site to digitalocean and when I went to the admin page the CSS was not showing

I visit all these sites but nothing seems to work

Django doc-static files

Pythonanywhere-DjangoStaticFiles

StackOverflow -why my django admin site does not have the css style

I set up my STATIC_ROOT and STATIC_URL, and then I ran

python manage.py collectstatic

And here is my seting

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,  '/home/django/django_project/django_project/static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static/'), 
]
waleed
  • 61
  • 1
  • 2
  • 9

2 Answers2

0

You are specifying an Absolute Path for your join.

os.path.join(BASE_DIR, arg2) means join the current directory that is being executed and append the second argument.

Ryan
  • 512
  • 1
  • 5
  • 17
0

add these lines into your settings.py file

STATICFILES_DIRS = (                                                            
 os.path.join(BASE_DIR, 'static/'),                                          
 )  
Shihabudheen K M
  • 1,347
  • 1
  • 13
  • 19
  • I did but nothing has changed. when I run it on the local server it works fine but when I go to production it doesn't show up – waleed Feb 27 '18 at 12:57
  • How do you serve the Django app in production? Without more information about your configuration (nginx confs, gunicorn, etc) we won't be able to help you. – Oliver Feb 27 '18 at 14:02
  • is nginx serve your static files you should add these line in nginx.conf location /static/ { alias /home//; } – Shihabudheen K M Feb 28 '18 at 03:55