I'm trying to use the Admin Widgets with a couple of DateField on my formulary but only the first of them gets the widget displayed correctly, for the other one I get an error:
DateTimeShortcuts.js:205 Uncaught ReferenceError: django is not defined
(The line indicated is:
django.jQuery(document).bind('keyup', function(event) {
)
Here's my template head:
<head>
{% load adminmedia %}
<link rel="stylesheet" href="/static/css/main.css" />
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript">
window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
</script>
<link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css"/>
<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css"/>
<!-- <link rel="stylesheet" type="text/css" href="/static/admin/css/global.css"/> -->
<link rel="stylesheet" type="text/css" href="/static/admin/css/widgets.css"/>
{{ form.media }}...
My model fields:
start_date = models.DateField()
end_date = models.DateField()
And my form class:
class UserForm(ModelForm):
start_date = forms.DateField(
widget=widgets.AdminDateWidget
)
end_date = forms.DateField(
widget=widgets.AdminDateWidget
)
class Meta:
model = User
I guess it some kind of rendering rule but I'm totally confused. Any help is welcome!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…