Changeset - 9eb76f6574ce
[Not reviewed]
0 2 0
Branko Majic (branko) - 9 years ago 2016-10-22 23:56:34
branko@majic.rs
MDT-3: Fixed BASE_DIR and ASSETS_ROOT in base.py. Added some usage instructions for project templates on serving static and media files.
2 files changed with 25 insertions and 2 deletions:
0 comments (0 inline, 0 general)
docs/usage.rst
Show inline comments
 
@@ -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
 
------------------------
 

	
project-django-1.8/project_name/settings/base.py
Show inline comments
 
@@ -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 = (
0 comments (0 inline, 0 general)