Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11543

Django admin not serving static files on Apache

I've seen similar questions but they are more than 4 years old and the answers doesn't work anymore. I have a site that works correctly on Apache, except for the admin staticfiles. The staticfiles work fine with Django's runserver. I'm kind of lost here, any advice will help.

Upvotes: 0

Views: 670

Answers (2)

cutteeth
cutteeth

Reputation: 2213

When you serve static files using apache, static folder is supposed to be in your /var/www/html directory. I had gone through same scenario as yours. collectstatic didnt work for me. What I did was, copied static contents of admin app to /var/www/html/static/admin. This admin directory contains four other directories css, fonts, img and js. In my case apache setup was the default so /var/www/html was my public directory. Following can be used for reference.

server
    |
    -var
       | 
        -www
            |
             -html
                  |
                  - static
                         |
                         -admin
                               |-css
                               |-fonts
                               |-img
                               |-js

You can try aforementioned approach. It would be helpful if you let know issue is resolved.

Upvotes: 0

Dawn T Cherian
Dawn T Cherian

Reputation: 5416

Check the following things

1)Did you add STATIC_ROOT in settings file?

2)After activating the virtual environment(if any), did you run

python manage.py collectstatic

Upvotes: 1

Related Questions