Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django static admin 404 for icon_clock.gif and icon_calender.gif

Tags:

python

django

There is one previous question that I could find:

Using Django and s3boto, some admin images (icon_clock.gif & icon_calendar.gif) don't display

But it is very dated (2013). I am running django 1.9.1, apache, wsgi on Ubuntu 14.04.3 LTS.

First the problem was that jquery files were missing, but running collectstatic (manage.py) from within the virtualenv fixed that problem. However, the two admin media files are still missing. The 404 URL calls are:

http://example.com/missing-admin-media-prefix/img/icon_calendar.gif
http://example.com/missing-admin-media-prefix/img/icon_clock.gif

The strange URL prefix leads one to find several very old questions related to that problem, but it seems to have been depreciated for django 1.9.1.

My settings.py looks like this:

STATIC_URL = '/static/'
#ADMIN_MEDIA_PREFIX = '/static/admin/'
#MEDIA_URL = "/media/"
#MEDIA_ROOT = "/home/user/app_root/media/"
STATIC_ROOT = "/home/user/app_root/static/"

The outcommented lines were suggestions I found in outdated questions related to the same problem (none worked). All other static files work fine, including most of the admin ones.

I've run out of ideas.

like image 725
CoderGuy123 Avatar asked Oct 18 '22 17:10

CoderGuy123


1 Answers

This error in django 1.9.1 means that the old version of javascript file 'django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js' is used since there's no 'missing-admin-media-prefix' text in the new version.

Maybe you should just reload page with shift-F5 or clear browser cache.

In case it doesn't help - check in browser console why the old version of file is used.

Updated from discussion in comments:

The problem was due to the older version of django installed globally via pip. To fix the problem the next steps vere done:
1) Old version of globally installed django was removed with pip uninstall django and pip3 uninstall django(outside the virtualenv);
2) Static files were recollected with python manage.py collectstatic -c where -c is option to clear existing files(with activated virtualenv);
3) Webserver was restarted.

like image 157
Alex Polekha Avatar answered Oct 30 '22 20:10

Alex Polekha