0

I need to solve the missing admin page css problem. I have tested almost all the solutions on the web with no luck! (I'm using django 1.8 on apache2.4)

Here's what I've done so far:

in setting.py I have:

INSTALLED_APPS = [
    ...
    django.contrib.staticfiles',
    ...
]

STATIC_URL = '/static/'
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

I did python manage.py collectstatic. It created the static folder: 63 static files copied to '/var/www/mysite/mysite/static'.

and then in etc/apache2/sites-available/000-default.conf I added:

Alias /static /var/www/mysite/mysit/static
<Directory /var/www/mysite/mysite/static>
    Require all granted
</Directory>

I also reloaded the apache.

It seems that I'm doing something wrong since the django admin doesn't show the css.

Any help would be appreciated.

5
  • 1
    have you done python manage.py collectstatic? Commented Nov 19, 2016 at 10:53
  • 2
    Possible duplicate of Django staticfiles app help Commented Nov 19, 2016 at 11:10
  • does your static files work correctly not in admin? Commented Nov 19, 2016 at 18:03
  • @dahrens yes, I did the python manage.py collectstatic and it successfully created the folder: 63 static files copied to '/var/www/mysite/mysite/static'. The [stackoverflow.com/questions/4565935/… staticfiles app help) is old and for django 1.3 Commented Nov 24, 2016 at 4:57
  • @ZagorodniyOlexiy No it doesn't. Commented Nov 24, 2016 at 5:23

2 Answers 2

1

"The steps presented in the question is actually correct to set the static files on apache server."

The problem was the typo I made in my apache server thread (the correct one is: Alias /static /var/www/mysite/mysite/static). Thanks to @Zagorodniy Olexiy for pointing it out.

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

Comments

0

After all you wrote I think that the problem is right of the files and directories of your project. Try customize it in this way:

1) Change the rights of all files in your project:

chmod 755 /var/www/mysite/*

2) Change rights to the folders of your project:

find /var/www/mysite/ -type f -exec chmod 644 {} \;

3) Change owner of your project:

chown -R www-data:www-data /var/www/mysite/*

Also you have typo in your apache server thread:

remove

Alias /static /var/www/mysite/mysit/static

to

Alias /static /var/www/mysite/mysite/static

Hope it helps you.

1 Comment

The problem was the "typo"! Thank you very much for pointing it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.