求解决 按照教程写的 不知为什么出错???
django吧
全部回复
仅看楼主
level 1
models.py中的内容是:
import datetime
from django.utils import timezone
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_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self):
return self.choice_text
运行报错了:
Traceback (most recent call last):
File "D:\python\lib\site-packages\django\conf\__init__.py", line 38, in _setup
settings_module = os.environ[ENVIRONMENT_VARIABLE]
File "D:\python\lib\os.py", line 631, in __getitem__
raise KeyError(key) from None
KeyError: *DJANGO_SETTINGS_MODULE*
2014年08月12日 08点08分 1
level 5
你确定 pub_date=models.DateTimeField(用*号而不是')?
2014年08月14日 12点08分 2
1