使用Django文档https://docs.djangoproject.com/en/3.0/intro/tutorial02/
开发我的第一个Django项目我已经进入管理部分,但是无论何时我进入/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\0001_initial.py first seen with mtime 1575315232.7083857
File ...Lib\site-packages\django\contrib\auth\migrations\0004_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\0001_initial.py first seen with mtime 1575315232.9317892
File ...Lib\site-packages\django\contrib\auth\migrations\0005_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\0009_alter_user_last_name_max_length.py first seen with mtime 1575315232.7153673
File ...Lib\site-packages\django\contrib\auth\migrations\0003_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,)
答案 0 :(得分:0)
您检查服务器日志了吗?
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,
},
},
}
答案 1 :(得分:0)
这是一个Django 3.0问题,多个人遇到了相同的问题。尝试降级到另一个版本,2.2可以工作
答案 2 :(得分:0)
在Mac上使用python 3.7时遇到了问题,因此我将virtualenv升级为使用python 3.8,此问题已解决。我注意到它也影响了通过该应用程序发送电子邮件。