【问题标题】:How to specify the location to place static files in django?如何指定在 django 中放置静态文件的位置?
【发布时间】:2017-01-11 22:33:44
【问题描述】:

使用django-admin startproject mysite 创建第一个项目后,您会得到一个如下所示的目录

mysite/
    manage.py       - script for running tasks
    mysite/
        __init__.py
        settings.py - for general setting configuration
        urls.py     - for routing configuration
        wsgi.py     - for webserver configuration

我想要的是 3 个目录,用于放置可在所有 django 应用程序中使用的各种文件。

mysite/
    manage.py       
    javascript_css/
        ...
    html_templates/
        ...
    custom_modules/
        ...
    mysite/
        __init__.py
        settings.py 
        urls.py     
        wsgi.py     

为了配置此行为,我需要更改 settings.py 中的哪些设置以及如何在我的 django 应用程序中引用 javascript_css/html_templates/custom_modules?

感谢您的帮助

【问题讨论】:

    标签: django python-3.x routing django-settings


    【解决方案1】:

    您可以在 django 文档中找到所有内容:

    1. static files
    2. html templates

    最好将文件夹命名为statictemplates,这样更易​​读。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-04
      • 2017-05-06
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      • 2014-11-19
      • 2020-06-19
      • 1970-01-01
      相关资源
      最近更新 更多