1

I'm using the admin datepicker in my form, but it is not displaying the clock and calendar images.

Here's the head of my template:

{% extends "shared/base.html" %}

{% load adminmedia %}

{% block extra_head %}

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}admin/css/forms.css"/>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}admin/css/base.css"/>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}admin/css/global.css"/>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}admin/css/widgets.css"/>

<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/core.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/admin/RelatedObjectLookups.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.init.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/actions.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/calendar.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/admin/DateTimeShortcuts.js"></script>

{% endblock %}

With this I get:

"GET /missing-admin-media-prefix/img/icon_clock.gif HTTP/1.1" 404 4049
"GET /missing-admin-media-prefix/img/icon_calendar.gif HTTP/1.1" 404 4058

So I added

 <script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{%admin_media_prefix %}{% endfilter %}";</script>

to the head and now I get:

"GET /media/admin/img/icon_calendar.gif HTTP/1.1" 404 4013
"GET /media/admin/img/icon_clock.gif HTTP/1.1" 404 4004

Any idea what I'm doing wrong? Do I need to change something in my settings.py?

ana
  • 475
  • 4
  • 10
  • 21
  • http://ilostmynotes.blogspot.com/2010/09/using-django-admin-time-and-date.html – catherine Mar 12 '13 at 10:58
  • I'm not in front of my development machine, but I believe you need to make a symbolic link to the admin images from within your static/media directory. See if this helps: http://stackoverflow.com/questions/5537268/django-admin-page-missing-css – themanatuf Mar 12 '13 at 11:31

1 Answers1

2

i was suffering with the same problem.All you need to do is add "ADMIN_MEDIA_PREFIX" in you settings.py file

just write

ADMIN_MEDIA_PREFIX = '/static/admin/'

if you have static directory in your project. name it according to your directory name. if its already named as static then use the above.

numerah
  • 498
  • 7
  • 29
  • Worked for me in Django 1.9.3. Do you have the [static media serving set up for local work?](https://docs.djangoproject.com/en/1.9/howto/static-files/#serving-static-files-during-development) – Tom Mar 08 '16 at 17:14