Django 管理后台日期和时间选择器无法使用

0 投票
1 回答
726 浏览
提问于 2025-04-17 09:43

我正在按照djangoproject.com上的四部分教程进行学习。

在第二部分(https://docs.djangoproject.com/en/1.3/intro/tutorial02/)中,我在设置管理界面,一切都正常,除了日期和时间的选择器没有出现。

我一步一步地跟着教程,所以我不知道自己哪里出错了。

而且,在admin/auth/user/1/页面上也没有这个选择器。

有没有什么想法?谢谢!

更新

这是我的代码:

--models.py--

import datetime

from django.db import models

class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __unicode__(self):
        return self.question

    def was_published_today(self):
        return self.pub_date.date() == datetime.date.today()

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(max_length=200)
    votes = models.IntegerField()

    def __unicode__(self):
        return self.choice

--admin.py--

from polls.models import Poll
from django.contrib import admin

admin.site.register(Poll)

1 个回答

0

这是一个关于Django安装的问题,我重新安装了一下,现在它正常工作了。

撰写回答