我目前坚持在 lubuntu 上使用 django 处理静态文件,不断收到错误 404,找不到文件。
我已经尝试了多种可能性,我已经用谷歌搜索过,但在我的情况下它们都不起作用。
我在我的主项目文件夹中的静态文件夹下有我的静态文件。
设置.py
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR,'templates')
STATIC_DIR = os.path.join(BASE_DIR,'static')
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'first_app',
]
STATIC_URL = '/static/'
STATICFILES_DIR = [
STATIC_DIR,
]
你能给我建议在 ubuntu 上处理静态文件的最糟糕的方法是什么,或者如果你在我的情况下看到任何解决方案?
最佳答案
请遵循本教程,Deploying Your Application (Option #1) - Deploy to a Linux Server
它完成了将您的应用程序成功部署到 ubuntu 服务器的所有步骤。
关于python - Django - 在 ubuntu 上找不到静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57129296/