1
我想要打包一个也包含脚本文件(angularJS)的django应用程序。当我创建一个exe文件时,它无法加载静态文件(404错误)。我试过 python manage.py collectstatic并从正确的位置复制文件。 但是,当我运行该exe文件时,它无法加载文件。在创建Django应用程序的pyinstaller exe时加载脚本文件
Theres一个相关的问题,但该解决方案没有解决问题。 Location of static files when creating a Django exe using pyinstaller
我的settings.py文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/res/'
STATIC_ROOT = os.path.join(BASE_DIR, "res")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'Rule/res'),
)
我的spec文件:
added_files = [
('Rule\\templates\\*.html','Rule\\templates'),
('Rule\\migrations','Rule\\migrations'),
('Rule\\res\\scripts\\*.js','Rule\\res\\scripts'),
]
它能够加载模板,但不是脚本文件。
我加载脚本文件在我的html文件是这样的:
{% block js %}
<script src='{% static "scripts/app.js" %}' ></script>
<script src='{% static "scripts/angular.js" %}'></script>
<script src='{% static "scripts/angular-ui-router.js" %}'></script>
<script src='{% static "scripts/angular-route.min.js" %}'></script>
<script src="{% static "scripts/ui-grid.min.js" %}"></script>
{%端块%}
请帮助我,如果我缺少something.Thanks