5

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.

Community
  • 1
  • 1
CoderGuy123
  • 6,219
  • 5
  • 59
  • 89

1 Answers1

3

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.

Alex Polekha
  • 1,590
  • 15
  • 13
  • I tried that of course. I don't know why it would use an old version. It works fine when using the developmental server (`manage.py runserver`). – CoderGuy123 Jan 29 '16 at 19:31
  • Look at your project's static files folder. Which version of script is there? – Alex Polekha Jan 29 '16 at 19:39
  • This project was created under 1.9.1, not imported from an earlier version. If the file is wrong there, then it is wrong in django 1.9.1. The django installation is a fresh install (via `apt-get`) in a virtual environment from a few days ago. – CoderGuy123 Jan 30 '16 at 02:47
  • apt-get installs django version from ubuntu repositories glibally, not in virtualenv. And it's the old version. You should activate your virtualenv and use pip install django or pip install django=1.9.1 – Alex Polekha Jan 30 '16 at 08:44
  • I did activate the virtualenv. The version is fine. – CoderGuy123 Jan 30 '16 at 16:14
  • 1
    Uninstall old version of django installed globally, not in your virtualenv, with `apt-get purge python-django`. Run `pip install django==1.9.1` and `python manage.by collectstatic` with virtualenv activated. Make sure your server uses python executable from virtualenv. That'll fix your problem. – Alex Polekha Jan 30 '16 at 17:09
  • 2
    Django was not installed via `apt-get` as I wrote above. It was installed via `pip` inside the `virtualenv`. Sorry for the confusion. I looked in the global environment. Django is installed there in versions 1.8.3, for both python2 and python3. I looked with `pip list` / `pip3 list`. I uninstalled these. Then I entered the `virtualenv` and used `python manage.py collectstatic -c`. The `-c` tells it to clear previous files first, to make sure that the right versions are there. Then I restarted the apache server. This fixed the issue. – CoderGuy123 Jan 31 '16 at 20:09
  • Could you update the answer to reflect this finding? That it may be fixed either by uninstalling django in the global environment or using the `collectstatic -c` call. I don't know which did the trick. – CoderGuy123 Jan 31 '16 at 20:10
  • Ran into this problem. This problem can exhibit itself if you switch between different projects. In my case, I'm working on a Django 1.7 project and a Django 1.9 one. It can be fixed by a hard browser refresh though. – Noel Llevares May 17 '16 at 15:44