Search code examples
python-3.xdjangoroutesdjango-settings

How to specify the location to place static files in django project?


After you create your first project with django-admin startproject mysite you get a directory that looks like this:

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

What I want is 3 directories for me to put various files that are usable across all django apps.

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

What settings would I need to change in settings.py in order to configure this behaviour and how would I reference the javascript_css/html_templates/custom_modules in my django apps?

Thanks for any help.


Solution

  • You can find everything in the django docs:

    1. static files
    2. html templates

    And it's probably better to keep folder named as static and templates, it's more readable.