python manage.py runserver 抛出错误

标签 python django

我是Python新手。我发出了以下命令:

django-admin startproject webserver

这创建了一个框架项目。之后,我跑了

python manage.py runserver 0.0.0.0:8001

我收到下面给出的错误。我无法启动服务器。请指导我?

C:\training\webserver\webserver>python manage.py runserver 0.0.0.0:8001
Unhandled exception in thread started by <function wrapper at 0x0000000003C872E8>
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
    six.reraise(*_exception)
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate
    app_config.import_models()
  File "C:\Python27\lib\site-packages\django\apps\config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Python27\lib\site-packages\django\contrib\auth\models.py", line 299, in <module>
    class AbstractUser(AbstractBaseUser, PermissionsMixin):
  File "C:\Python27\lib\site-packages\django\db\models\base.py", line 279, in __new__
    new_class.add_to_class(field.name, new_field)
  File "C:\Python27\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line 709, in contribute_to_class
    cls._meta.add_field(self)
  File "C:\Python27\lib\site-packages\django\db\models\options.py", line 277, in add_field
    self.local_fields.insert(bisect(self.local_fields, field), field)
  File "C:\Python27\lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),

最佳答案

在正确的创建过程中您可能会错过一些步骤。 我刚刚按照以下步骤在我的机器上测试了它:

  1. mkdir 测试
  2. cd 测试/
  3. virtualenv 测试(对我来说将创建一个 python 2.7 env)
  4. 源代码测试/bin/activate
  5. pip 安装 django
  6. django-admin startproject thistest
  7. cd 这个测试/
  8. python管理.py runserver 0.0.0.0:8001

Performing system checks...

System check identified no issues (0 silenced).

October 11, 2017 - 15:57:18 Django version 1.11.6, using settings

'thistest.settings' Starting development server at

http://0.0.0.0:8001/ Quit the server with CONTROL-C.

一切正常,请检查您是否遵循相同的步骤

关于python manage.py runserver 抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46682142/

相关文章:

Python str() - 指定要添加/使用哪种引号?

python - 如何安装旧版本的 django 软件包?

python - Django迁移1100万行,需要分解

python - 绘图 : using percentage on x axis

python - 访问结构化数组的 NumPy 数组的列

python - 如何在 Django Rest Framework 中通过 id 查找对象

python - 检查两个 'time ranges' 是否彼此重叠

javascript - Uncaught ReferenceError : stLight is not defined (in Chrome only)

django - 使用 Django ORM,如何在 Many 关系中过滤同一记录的两个字段?

mysql - 使用内容类型 (object_pk) 创建通用关系时出错