Changeset - 494880211827
[Not reviewed]
default
0 2 0
Branko Majic (branko) - 12 years ago 2013-08-17 17:29:52
branko@majic.rs
DMT-1: Calculate media and static files root directories automatically. Set the URLs for them to /media/ and /static/. Enable the Django admin app by default.
2 files changed with 17 insertions and 14 deletions:
0 comments (0 inline, 0 general) First comment
project/project_name/settings/base.py
Show inline comments
 
@@ -5,6 +5,12 @@
 
# project. Do not put any site-specific settings here.
 
#
 

	
 
from os import path
 

	
 
# Determine the Django project root directory.
 
PROJECT_ROOT = path.dirname(path.dirname(path.abspath(__file__)))
 
ASSETS_ROOT = path.normpath(path.join(PROJECT_ROOT, "assets"))
 

	
 
# Language code for this installation. All choices can be found here:
 
# http://www.i18nguy.com/unicode/language-identifiers.html
 
LANGUAGE_CODE = 'en-us'
 
@@ -22,20 +28,17 @@ USE_L10N = True
 
# If you set this to False, Django will not use timezone-aware datetimes.
 
USE_TZ = True
 

	
 
# Absolute filesystem path to the directory that will hold user-uploaded files.
 
# Example: "/var/www/example.com/media/"
 
MEDIA_ROOT = ''
 
# Absolute filesystem path to the directory that will hold user-uploaded
 
# files. Calculated based on project root.
 
MEDIA_ROOT = path.normpath(path.join(ASSETS_ROOT, "media"))
 

	
 
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
 
# trailing slash.
 
# Examples: "http://example.com/media/", "http://media.example.com/"
 
MEDIA_URL = ''
 
MEDIA_URL = '/media/'
 

	
 
# 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: "/var/www/example.com/static/"
 
STATIC_ROOT = ''
 
# Absolute path to the directory static files should be collected to. Calculated
 
# based on project root.
 
STATIC_ROOT = path.normpah(path.join(ASSETS_ROOT, "static"))
 

	
 
# URL prefix for static files.
 
# Example: "http://example.com/static/", "http://static.example.com/"
 
@@ -92,7 +95,7 @@ INSTALLED_APPS = (
 
    'django.contrib.messages',
 
    'django.contrib.staticfiles',
 
    # Uncomment the next line to enable the admin:
 
    # 'django.contrib.admin',
 
    'django.contrib.admin',
 
    # Uncomment the next line to enable admin documentation:
 
    # 'django.contrib.admindocs',
 
)
project/project_name/urls.py
Show inline comments
 
from django.conf.urls import patterns, include, url
 

	
 
# Uncomment the next two lines to enable the admin:
 
# from django.contrib import admin
 
# admin.autodiscover()
 
from django.contrib import admin
 
admin.autodiscover()
 

	
 
urlpatterns = patterns('',
 
    # Examples:
 
@@ -13,5 +13,5 @@ urlpatterns = patterns('',
 
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
 

	
 
    # Uncomment the next line to enable the admin:
 
    # url(r'^admin/', include(admin.site.urls)),
 
    url(r'^admin/', include(admin.site.urls)),
 
)
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now