开发者社区> 问答> 正文

执行 python manage.py runserver 0.0.0.0:80?报错

python manage.py runserver 0.0.0.0:8080

Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x2af27879d578>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check_migrations()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 437, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in init
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in init
    self.build_graph()
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 203, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 56, in ensure_schema
    with self.connection.schema_editor() as editor:
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 25, in enter
    self._initial_pragma_fk = c.fetchone()[0]

TypeError: 'NoneType' object has no attribute 'getitem'

环境说明:

# python
Python 2.7.12 (default, Sep 27 2016, 00:24:04)

# which python
/usr/local/bin/python

# which django-admin
/usr/local/bin/django-admin


展开
收起
爱吃鱼的程序员 2020-06-09 10:18:21 1235 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    等了2天,没有人回答,我自己搞定了,根据错误“self.check_migrations()”和(connections[DEFAULT_DB_ALIAS])来判断,是因为连接数据库的问题。

    解决办法:我重新配置了settings.py文件,把里面默认django.db.backends.sqlite3改成了django.db.backends.mysql引擎。然后又安装了MySQL-python。创建了mysql的数据库。最终启动不再报错,顺利执行。

    上面就是我自己搞定的方法,贴出来给大家一个帮助吧。

    比较基本的debug,所以没有人回答
    2020-06-09 10:18:37
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载