Django安装教程

时间:2013-12-03 12:28:06

标签: django

我是django的新手,并尝试按照教程完成django。但是,我无法进入下一个指南。当我输入Poll.objects.all()时。我收到几个错误。以下提供完整信息。

>>> Poll.objects.all()
   Traceback (most recent call last):
   File "<pyshell#11>", line 1, in <module>
   Poll.objects.all()
    File "C:\Python26\lib\site-packages\django\db\models\query.py", line 93, in __repr__
     data = list(self[:REPR_OUTPUT_SIZE + 1])
     File "C:\Python26\lib\site-packages\django\db\models\query.py", line 108, in __len__
    self._result_cache.extend(self._iter)
    File "C:\Python26\lib\site-packages\django\db\models\query.py", line 317, in iterator
    for row in compiler.results_iter():
   File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py", line 775,   in             results_iter
for rows in self.execute_sql(MULTI):
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\util.py", line 41, in execute
return self.cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\sqlite3\base.py", line 366, in execute
 six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
File "C:\Python26\lib\site-packages\django\db\backends\sqlite3\base.py", line 362, in execute
 return Database.Cursor.execute(self, query, params)
DatabaseError: no such column: polls_poll.pub_date

1 个答案:

答案 0 :(得分:0)

由于问题中给出的代码不够充分,我将向您提供两个可能的错误:

1)从未创建过pub_date列

2)创建了pub_date列,但是先创建了表。因此,python manage.py syncdb 将列添加到现有表中。

因此,从SQL中删除表,然后再次执行syncdb以解决此问题。如果您不想删除该表,请使用south