【发布时间】:2019-11-29 10:36:57
【问题描述】:
我目前坚持在 lubuntu 上使用 django 处理静态文件,不断收到错误 404,找不到文件。
我已经尝试了多种可能性,我在谷歌上搜索过,但在我的情况下都没有。
我的静态文件位于我的主项目文件夹中的静态文件夹下。
settings.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 上处理静态文件的最糟糕的方法是什么,或者如果你在我的情况下看到任何解决方案?
【问题讨论】:
-
您是否已将您的 peoject 作为 apache 部署到服务器中?
-
您有
STATIC_ROOT设置吗?你跑collectstatic了吗? -
我认为不是。你能告诉我怎么做吗?
-
我推荐阅读documentation,它相当全面
标签: python django python-3.x ubuntu django-staticfiles