如何在Django中修复这些错误?

时间:2013-09-23 06:32:15

标签: python django

我是一个python / django noob,在尝试学习时无法运行我的代码。请告诉我如何解决以下我遇到的错误,谢谢。

在我的新项目的根文件夹中,我在命令行输入以下内容,这就是:

  

python manage.py runserver

     

验证模型......

>/Users/MyClean/anaconda/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
  DeprecationWarning)

>Unhandled exception in thread started by <bound method Command.inner_run of <django.core.management.commands.runserver.Command object at 0x101a00c50>>
Traceback (most recent call last):
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run
    self.validate(display_num_errors=True)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/core/management/base.py", line 280, in validate
    num_errors = get_validation_errors(s, app)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/db/models/loading.py", line 166, in get_app_errors
    self._populate()
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
    self.load_app(app_name, True)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/db/models/loading.py", line 96, in load_app
    models = import_module('.models', app_name)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/djangodblog/models.py", line 40, in <module>
    class ErrorBase(Model):
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/djangodblog/models.py", line 46, in ErrorBase
    url             = models.URLField(verify_exists=False, null=True, blank=True)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1277, in __init__
    CharField.__init__(self, verbose_name, name, **kwargs)
  File "/Users/MyClean/anaconda/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 626, in __init__
    super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'verify_exists''

我查看了我的项目代码(这是非常基本的)并且没有看到任何拼写错误。我正在从一本3岁的书中复制,所以我认为这是一个兼容性问题。

1 个答案:

答案 0 :(得分:1)

  我正在复制一本3岁的书,所以我认为这是一本书   兼容性问题。

3年是很长的一段时间。

在django 1.4中,verify_exists选项已被弃用(这意味着它被标记为删除),而在1.5中它被完全删除。

由于1.5是当前版本,因此当您安装django时,这是已安装的版本。

当你走过一本书时,尝试使用相同版本的django作为书。否则你会遇到更多这些问题。

或者,使用更新的参考。为什么不试试official tutorial