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

There is one previous question that I could find:

Using Django and s3boto, some admin images (icon_clock.gif and icon_calendar.gif) are not displayed

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

At first the problem was that the jquery files were missing, but collectstatic ( manage.py ) was launched from virtualenv , this problem was fixed. However, two media files for administration files are still missing. 404 URLs:

 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 allows you to find some very old questions related to this problem, but it seems to have 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 lines outlined were suggestions that I found in outdated questions related to the same problem (no one worked). All other static files work fine, including most of them.

I'm out of ideas.

+5
source share
1 answer

This error in django 1.9.1 means that the old javascript version of the file โ€œdjango / contrib / admin / static / admin / js / admin / DateTimeShortcuts.jsโ€ is used, because there is no โ€œmissing-admin-media-prefixโ€ prefix in the new version.

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

If this does not help, check in the browser console why the old version of the file is used.

Updated from discussion in comments:

The problem arose because of the old version of django installed globally through pip. To resolve the problem, the following steps were taken:
1) The old version of the fully installed django was removed using pip uninstall django and pip3 uninstall django (outside of virtualenv); 2) Static files were stored using python manage.py collectstatic -c , where -c is the option to clean existing files (with virtualenv activated);
3) The web server has been restarted.

+3
source

Source: https://habr.com/ru/post/1241504/


All Articles