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.

S_M
  • 290
  • 3
  • 18
  • 1
    have you done `python manage.py collectstatic`? – dahrens Nov 19 '16 at 10:53
  • 2
    Possible duplicate of [Django staticfiles app help](http://stackoverflow.com/questions/4565935/django-staticfiles-app-help) – dahrens Nov 19 '16 at 11:10
  • does your static files work correctly not in admin? – Zagorodniy Olexiy Nov 19 '16 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 [http://stackoverflow.com/questions/4565935/django-staticfiles-app-help](Django staticfiles app help) is old and for django 1.3 – S_M Nov 24 '16 at 04:57
  • @ZagorodniyOlexiy No it doesn't. – S_M Nov 24 '16 at 05:23

2 Answers2

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.

S_M
  • 290
  • 3
  • 18
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.

Zagorodniy Olexiy
  • 2,132
  • 3
  • 22
  • 47