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/\'
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')],
First make sure that django.contrib.staticfiles
is included in your INSTALLED_APPS
in settings.py
. Then have to insert in your settings.py
for example this one:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
I hope definition of BASE_DIR
you have in the top of settings.py
. BASE_DIR
points to a folder, where your manage.py
file exists. So if you would have static files in the same dir, then you leave above setting as it is. If not, let's say in the same dir, next to manage.py
you will have folder named app
, then your settings should look like:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "app/static"),
]
And you can even run:
python manage.py collectstatic
To get admin static files into your static directory.
Hope that helps.
This looks like it might be an issue with where the PyInstaller packed python script looks for static files. They are placed in a temporary folder and need to be accessed by an absolute path. Check out this issue: Bundling data files with PyInstaller (--onefile)