From 9eb76f6574cede1d7f6d793c71d3ff4c317a8864 2016-10-22 23:56:34 From: Branko Majic Date: 2016-10-22 23:56:34 Subject: [PATCH] MDT-3: Fixed BASE_DIR and ASSETS_ROOT in base.py. Added some usage instructions for project templates on serving static and media files. --- diff --git a/docs/usage.rst b/docs/usage.rst index ad205757280d83d2fc975bb6491b7a1bd8890312..29e5b386b8673473d2c47b13a2ade466fc0369df 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -130,6 +130,29 @@ you would run:: pip install pip install requirements/development.txt +Serving of static and media files +--------------------------------- + +Out of the box, project templates will configure ``/static/`` as base URL for +static files, and ``/media/`` as base URL for media. + +Root directories for locating static and media files are set-up to point to +parent directory of project (so, one level up from ``manage.py``), in +directories ``assets/static/`` and ``assets/media/``. + +As an example, in case you create project in ``~/tmp/``, you would have +structure similar to: + +- ``~/tmp/myproject/`` +- ``~/tmp/myproject/manage.py`` +- Many other files and directories under ``~/tmp/myproject/`` +- ``~/tmp/assets/static/`` +- ``~/tmp/assets/media/`` + +This way you can keep the assets (static and media files) outside of the project +code tree. + + Working with the project ------------------------ diff --git a/project-django-1.8/project_name/settings/base.py b/project-django-1.8/project_name/settings/base.py index b5cf9be48f77ed1b1dde7e91196cd2ea0c47b95c..4808eff65c962dc8bd8887413843c832e8f36a5d 100644 --- a/project-django-1.8/project_name/settings/base.py +++ b/project-django-1.8/project_name/settings/base.py @@ -25,8 +25,8 @@ import os # Base and assets project directories. -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -ASSETS_ROOT = os.path.normpath(os.path.join(BASE_DIR, "assets")) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +ASSETS_ROOT = os.path.normpath(os.path.join(os.path.dirname(BASE_DIR), "assets")) # List of installed applications. INSTALLED_APPS = (