当 127.0.0.1:<port>/admin/URL 被命中时,Django 管理服务器关闭
Django admin server shuts down when 127.0.0.1:<port>/admin/ URL is hit
使用 Django 文档开发我的第一个 Django 项目https://docs.djangoproject.com/en/3.0/intro/tutorial02/
我已经进入了管理部分,但是每当我进入 /admin/
时,Django 服务器都会关闭并且没有任何错误消息(例如按 CTRL + C)。
我试过的
1. 运行 不同端口的服务器
2.新建一个Django项目
3. 从任务管理器
停止了python 个进程
这让我发疯,因为当我转到 127.0.0.1:<port>/app/index
时它工作正常
但服务器在
时关闭
以下是 django 服务器日志
File ...Python\Python37-32\Lib\stringprep.py first seen with mtime 1530068518.0
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]01_initial.py first seen with mtime 1575315232.7083857
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]04_alter_user_username_opts.py first seen with mtime 1575315232.7103803
File ...Lib\site-packages\django\contrib\admin\migrations\__init__.py first seen with mtime 1575315232.064109
File ...Lib\site-packages\django\contrib\contenttypes\migrations[=12=]01_initial.py first seen with mtime 1575315232.9317892
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]05_alter_user_last_login_null.py first seen with mtime 1575315232.711378
File ...Lib\site-packages\PIL\_imaging.cp37-win32.pyd first seen with mtime 1575317072.293999
File ...Lib\site-packages\django\contrib\admin\templatetags\admin_list.py first seen with mtime 1575315232.244624
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]09_alter_user_last_name_max_length.py first seen with mtime 1575315232.7153673
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]03_alter_user_email_max_length.py first seen with mtime 1575315232.709383
(0.000) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."expire_date" > '2019-12-08 00:29:28.033564' AND "django_session"."session_key" = '2okb8vdor5ydpa06vd97opvzhuqyxt51') LIMIT 21; args=('2019-12-08 00:29:28.033564', '2okb8vdor5ydpa06vd97opvzhuqyxt51')
(0.000) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21; args=(1,)
你检查过服务器日志了吗?它说了什么?
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/path/to/django/debug.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
这是一个 Django 3.0 问题,很多人都遇到过同样的问题。尝试降级到另一个版本,2.2 有效
我在 mac 上使用 python 3.7 时遇到问题,因此我将 virtualenv 升级为使用 python 3.8,问题已解决。我注意到它也影响了通过应用程序发送电子邮件。
使用 Django 文档开发我的第一个 Django 项目https://docs.djangoproject.com/en/3.0/intro/tutorial02/
我已经进入了管理部分,但是每当我进入 /admin/
时,Django 服务器都会关闭并且没有任何错误消息(例如按 CTRL + C)。
我试过的 1. 运行 不同端口的服务器 2.新建一个Django项目 3. 从任务管理器
停止了python 个进程这让我发疯,因为当我转到 127.0.0.1:<port>/app/index
时它工作正常
但服务器在
以下是 django 服务器日志
File ...Python\Python37-32\Lib\stringprep.py first seen with mtime 1530068518.0
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]01_initial.py first seen with mtime 1575315232.7083857
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]04_alter_user_username_opts.py first seen with mtime 1575315232.7103803
File ...Lib\site-packages\django\contrib\admin\migrations\__init__.py first seen with mtime 1575315232.064109
File ...Lib\site-packages\django\contrib\contenttypes\migrations[=12=]01_initial.py first seen with mtime 1575315232.9317892
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]05_alter_user_last_login_null.py first seen with mtime 1575315232.711378
File ...Lib\site-packages\PIL\_imaging.cp37-win32.pyd first seen with mtime 1575317072.293999
File ...Lib\site-packages\django\contrib\admin\templatetags\admin_list.py first seen with mtime 1575315232.244624
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]09_alter_user_last_name_max_length.py first seen with mtime 1575315232.7153673
File ...Lib\site-packages\django\contrib\auth\migrations[=12=]03_alter_user_email_max_length.py first seen with mtime 1575315232.709383
(0.000) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."expire_date" > '2019-12-08 00:29:28.033564' AND "django_session"."session_key" = '2okb8vdor5ydpa06vd97opvzhuqyxt51') LIMIT 21; args=('2019-12-08 00:29:28.033564', '2okb8vdor5ydpa06vd97opvzhuqyxt51')
(0.000) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21; args=(1,)
你检查过服务器日志了吗?它说了什么?
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/path/to/django/debug.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
这是一个 Django 3.0 问题,很多人都遇到过同样的问题。尝试降级到另一个版本,2.2 有效
我在 mac 上使用 python 3.7 时遇到问题,因此我将 virtualenv 升级为使用 python 3.8,问题已解决。我注意到它也影响了通过应用程序发送电子邮件。