更新时间:2023-12-01 22:45:10
请参阅 https://docs.djangoproject.com/en/1.10/howto/static-files/ 您的urls.py文件中
,您应该添加类似于
从django.conf导入设置
from django.conf.urls.static import static
urlpatterns = [
url(r'^ login $', login = name ='login'),
] + static(settings.STATIC_URL,document_root = settings.STATIC_ROOT)
并在你的app.spec文件中添加数据
datas = [('xxx / templates' 'xxx / templates'),
('xxx / static','xxx / static')],
I have a Django project with the following structure: root videos static templates
and the STATIC_URL setting in settings.py is STATIC_URL = '/static/'
I managed to use pyinstaller to create a windows executable from manage.py. I can start the Django server but I can't figure out where to put the static files.
When I first started the server it could not find the templates as well, it searched for them in : 'root\django\contrib\admin\templates\videos\' I copied the templates to this folder and it worked. But I can't figure out where to put the static files. I tried putting them in 'root\django\contrib\admin\static' to recreate the original structure. But it seems it doesn't search for them there...
Anyone knows where the static files should go? Or how to define the place where a bundled pyinstaller exe will look for them ?
please see https://docs.djangoproject.com/en/1.10/howto/static-files/
in your urls.py file, you should add something like blew
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^login$', login, name='login'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
and in your app.spec file, add datas
datas=[('xxx/templates','xxx/templates'),
('xxx/static','xxx/static')],