我正在尝试使用相同的表单来管理页面中使用的日期和时间,但是在自定义页面中。
我已经创建了一个这样的表单类:
from django import forms
from django.contrib.admin import widgets as adminWidget
class RequestData(forms.Form):
data = forms.DateField(widget=adminWidget.AdminDateWidget())
当我在模板中显示此表单时,它在管理页面中看起来不像
答案 0 :(得分:0)
将此添加到您的模板(可能是base.html)
{% load admin_static %}
如果不起作用,请添加:
<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css" />
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
<script type="text/javascript" src="/static/admin/js/actions.js"></script>
<script type="text/javascript" src="/static/admin/js/urlify.js"></script>
<script type="text/javascript" src="/static/admin/js/prepopulate.js"></script>
<script type="text/javascript" src="/static/admin/js/vendor/xregexp/xregexp.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>
<script type="text/javascript" src="/static/admin/js/inlines.js"></script>