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/'), ] 
2
  • 1
    How have you deployed it? Have you made sure your nginx/apache is configured to serve your static files? Commented Feb 26, 2018 at 20:18
  • You were right there was a problem in my configuration file, Thanks @JonClements Commented Feb 28, 2018 at 8:54

2 Answers 2

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.

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

2 Comments

so should I write it like this
STATIC_ROOT ='/home/django/django_project/django_project/static'
0

add these lines into your settings.py file

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

3 Comments

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
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.
is nginx serve your static files you should add these line in nginx.conf location /static/ { alias /home/<your_path_to_static_root>/; }

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.