Django 1.2 DateField 管理站点问题
所以,我正在制作一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论