python - Django 1.4 中的静态文件夹结构?

标签 python django convention directory-structure django-1.4

这是新的项目结构(来自 Django 1.4 发行说明)。

myproject
|-- manage.py
|-- myproject
|   |-- __init__.py
|   |-- settings.py
|   |-- urls.py
|   `-- wsgi.py
`-- polls
    |-- __init__.py
    |-- models.py
    |-- tests.py
    `-- views.py

我不确定的是我是否应该将 STATIC_ROOT 指向

myproject/myproject/static/(连同 settings.py、urls.py...)

顶级目录myproject/static(在myproject、myapp1、myapp2旁边)?

最佳答案

STATIC_ROOT 与 Python 导入无关,因此完全取决于您。通常,myproject/static/,因此 os.path.join(PROJECT_ROOT, 'static/') 在设置中更容易。

按照 San4ez 的建议更新,并在 settings.py 中注释

# Absolute path to the directory static files should be collected to.  
# Don't put anything in this directory yourself; store your static files  
# in apps' "static/" subdirectories and in STATICFILES_DIRS.  
# Example: "/home/media/media.lawrence.com/static/"  

根据您的结构,最好将 poll 应用程序的静态文件放入 poll/static/

关于python - Django 1.4 中的静态文件夹结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10168761/

相关文章:

python - Tkinter:在主循环中调用事件

django - 如何在管理内联中用实际对象的字段替换 content_type 和 object_id 字段?

c# - 先入为主 C# : strange way to create a read-only property

java - @ComponentScan basePackageClasses 有命名约定吗?

python - 如何从内部 if 语句退出外部循环

python - 从 `urllib2.urlopen` 获取错误文本

python - apscheduler - 多个实例

rust - 如何在 Rust 中使用链式方法调用编写惯用的构建模式?

python - 如何查询两个表,表1中的某些项与表2没有关联?

python - AWS Elastic Beanstalk Django - 部署到 EB 时首先发生什么,pip install -r requirements.txt 或配置文件中的命令