开发者

Missing datepicker in Django 1.3 admin

Using Django 1.3, I am unable to see a datepicker for a Date or DateTime field in admin.

Model

Class xxxx: departure_date = models.DateTimeField(verbose_name = 'Departure Date')

Admin

from django.forms import ModelForm admin.site.regi开发者_开发问答ster(models.Schedule)

settings.py

MEDIA_ROOT = "/mnt/django/project_green/media/" MEDIA_URL = '/media/' STATIC_ROOT = "/mnt/django/project_green/static/" STATIC_URL = '/static/' ADMIN_MEDIA_PREFIX = '/static/admin/'

apache access.log

Seeing this weird 404 error "GET /mnt/django/project_green/admin/jsi18n/ HTTP/1.1" 404 1159

source of admin page

<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" /> <link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css" /> <!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="/static/admin/css/ie.css" /><![endif]-->

<script type="text/javascript">window.__admin_media_prefix__ = "/static/admin/";</script>

<script type="text/javascript" src="/mnt/django/project_green/admin/jsi18n/"></script> <script type="text/javascript" src="/static/admin/js/core.js"></script> <script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"> <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script> <script type="text/javascript" src="/static/admin/js/jquery.init.js"></script> <script type="text/javascript" src="/static/admin/js/actions.min.js"></script> <script type="text/javascript" src="/static/admin/js/calendar.js"></script> <script type="text/javascript" src="/static/admin/js/admin/DateTimeShortcuts.js"></script>

Thanks George


I experienced the same problem: not being able to see date picker in django admin. The cause of the problem was a bug in collectstatic command: https://code.djangoproject.com/ticket/15636

I ran collectstatic on Windows, and because of the bug, file /static/admin/js/admin/DateTimeShortcuts.js became lowercased: datetimeshortcuts.js So when I deployed it on Linux to be served by Apache, link /static/admin/js/admin/DateTimeShortcuts.js gave 404 error. Solution is simple: either migrate to Django 1.4 or run collectstatic on Linux.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜