Robby
Robby

Reputation: 401

collectstatic fails to collect admin static files

I face below error when I run collectstatic and Admin page is served without css.

Error:

IOError: [Errno 2] No such file or directory: u'/usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/img/gis/move_vertex_off.png

Below are the settings.

STATIC_ROOT = '/var/www/mysite/media/'

STATIC_URL = '/static/'

ADMIN_MEDIA_PREFIX = '/static/admin/'

What does this error message mean? The file does exist in the mentioned path.

Upvotes: 2

Views: 8122

Answers (3)

elimisteve
elimisteve

Reputation: 1831

I solved this problem by running python manage.py collectstatic then adding the following to my Apache config:

Alias /static/admin/ /PATH/TO/MY/PROJECT/static_root/admin/

<Directory /PATH/TO/MY/PROJECT/static_root/admin>
Require all granted
</Directory>

Upvotes: 0

Wim Feijen
Wim Feijen

Reputation: 874

By default, collectstatic looks in all locations defined in STATICFILES_DIRS and in the 'static' directory of apps specified by the INSTALLED_APPS setting (see: https://docs.djangoproject.com/en/dev/howto/static-files/ and https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/).

So if you added the admin to your INSTALLED_APPS, this should be fine.

The ADMIN_MEDIA_PREFIX is no longer used in current versions of Django.

Upvotes: 2

Robby
Robby

Reputation: 401

I assume the problem was due to some installation error. Re-installation of django did not help. Completely re-installed the OS as that was the quicker solution for me and things went fine. But still the root cause continues to be a mystery for me.

Upvotes: 2

Related Questions