Django 1.2 DateField 管理站点问题

发布于 2024-09-11 16:12:51 字数 549 浏览 2 评论 0原文

所以,我正在制作一个 Django 1.2 应用程序,但我在管理站点上遇到了问题。这是 models.py:

from django.db import models
from django.contrib.auth.models import User
import datetime

class Dailysales(models.Model):
    salesdate = models.DateField(primary_key=True)
    ...
def __unicode__(self):
    return self.salesdate.strftime("%B/%d/%Y")

我的问题是在管理站点中,销售日期字段显示为文本输入。据我所知,我对 Django 1.1 做了完全相同的事情,它给了我 datepicker 小部件。我不知道它是否与 1.2 有关,或者我只是无意中搞砸了其他东西,但我不确定还应该看什么,因为我能找到的所有文档都说这应该可以工作。如果模型说它是一个 DateField,那么还需要发生什么才能使管理站点显示日期选择器?任何关于在哪里调查的提示都值得赞赏。

So, I'm making a Django 1.2 app, and I'm having a problem with the admin site. Here's the models.py:

from django.db import models
from django.contrib.auth.models import User
import datetime

class Dailysales(models.Model):
    salesdate = models.DateField(primary_key=True)
    ...
def __unicode__(self):
    return self.salesdate.strftime("%B/%d/%Y")

My problem is that in the admin site, the salesdate field is showing up as a text input. I did as far as I can tell exactly the same thing with Django 1.1, and it gave me the datepicker widget. I don't know if it's related to 1.2 or I've just screwed something else up unintentionally, but I'm not sure what else to look at since all the documentation I can find says this should Just Work. If the model says it's a DateField, what else needs to happen to cause the admin site to show the datepicker? Any hints on where to investigate are appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文