【问题标题】:I am facing to start runserver django?我正面临启动runserver django?
【发布时间】:2017-02-27 20:39:43
【问题描述】:

在运行服务器时出现以下错误。我使用 Django===1.10.2 和默认 sqlite3 数据库作为后端。但我得到了以下例外:

python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7f56983c3140>
Traceback (most recent call last):
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check_migrations()
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/core/management/base.py", line 437, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
    self.build_graph()
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 203, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in ensure_schema
    raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 6: ordinal not in range(128)

任何解决方案都可以欣赏????

【问题讨论】:

  • 您在运行服务器之前迁移过数据库吗?
  • 我无法迁移..当我运行此命令时,它显示相同的错误..
  • 您的数据库名称中有“ñ”字符吗?或者可能是一个表名?
  • 我不这么认为...这是我第一次运行runserver
  • 我在 Centos - Python2.7 - Django 1.10 上也遇到同样的错误

标签: django sqlite


【解决方案1】:

您似乎在某处设置了一个奇怪的字符,很可能是在 django 设置中指定的 sqlite 文件的名称中。

Django 在尝试执行 raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc) 时死了 - 这样做时会遇到 UNICODE 错误,该错误表明 0xf1 不是 ASCII 的一部分。基于this table,这是字符±。由于 django 肯定不会将其用作表名,我想它一定与文件名有关。

如果不是这种情况,请尝试在您的项目文件夹中使用grep '±' . 来查找此字符的用法。高温

【讨论】:

    猜你喜欢
    • 2019-04-14
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多