运行SL服务器命令在Django中不起作用,使用pyinstaller构建的可执行文件



我正在使用runsslserver命令来运行django应用程序。 在命令行上生成其可执行文件并正常工作 例如,

Validating models...
System check identified no issues (0 silenced).
June 11, 2018 - 16:57:54
Django version 2.0.4, using settings 'XApp.settings'
Starting development server at https://0:8002/
Quit the server with CTRL-BREAK.

Settings.py

INSTALLED_APPS = (...
"sslserver",
...
)

当我使用 pyinstaller 构建可执行文件时(我已经将包包含在.spec文件中,例如Analysis(hiddenimports=[...,'sslserver',...])并与命令XApp.exe runsslserver 8000一起使用,然后它会显示如下消息,

Unknown command: 'runsslserver'
Type 'manage.py help' for usage.

我该如何解决?

我通过在命令字典中添加"runsslserver":'sslserver'找到了解决方案。

PyInstallerloaderrthookspyi_rth_django.py文件。

import django.core.management
import django.utils.autoreload

def _get_commands():
# Django groupss commands by app.
# This returns static dict() as it is for django 1.8 and the default project.
commands = {
'changepassword': 'django.contrib.auth',
'check': 'django.core',
'clearsessions': 'django.contrib.sessions',
'collectstatic': 'django.contrib.staticfiles',
'compilemessages': 'django.core',
'createcachetable': 'django.core',
'createsuperuser': 'django.contrib.auth',
'dbshell': 'django.core',
'diffsettings': 'django.core',
'dumpdata': 'django.core',
'findstatic': 'django.contrib.staticfiles',
'flush': 'django.core',
'inspectdb': 'django.core',
'loaddata': 'django.core',
'makemessages': 'django.core',
'makemigrations': 'django.core',
'migrate': 'django.core',
'runfcgi': 'django.core',
'runserver': 'django.core',
'runsslserver':'sslserver',
'shell': 'django.core',
'showmigrations': 'django.core',
'sql': 'django.core',
'sqlall': 'django.core',
'sqlclear': 'django.core',
'sqlcustom': 'django.core',
'sqldropindexes': 'django.core',
'sqlflush': 'django.core',
'sqlindexes': 'django.core',
'sqlmigrate': 'django.core',
'sqlsequencereset': 'django.core',
'squashmigrations': 'django.core',
'startapp': 'django.core',
'startproject': 'django.core',
'syncdb': 'django.core',
'test': 'django.core',
'testserver': 'django.core',
'validate': 'django.core'
}
return commands

最新更新