简体   繁体   中英

CSS is not showing in the admin page -Django

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/'), 
]

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.

add these lines into your settings.py file

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM