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)
project/project_name/settings/base.py
Show inline comments
 
@@ -2,12 +2,18 @@
 

	
 
#
 
# This file contains common settings shared amongst all instances of a
 
# 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'
 

	
 
SITE_ID = 1
 

	
 
@@ -19,26 +25,23 @@ USE_I18N = True
 
# calendars according to the current locale.
 
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/"
 
STATIC_URL = '/static/'
 

	
 
# Additional locations of static files
 
@@ -89,13 +92,13 @@ INSTALLED_APPS = (
 
    'django.contrib.contenttypes',
 
    'django.contrib.sessions',
 
    'django.contrib.sites',
 
    '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',
 
)
 

	
 
# A sample logging configuration. The only tangible logging
 
# performed by this configuration is to send an email to
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:
 
    # url(r'^$', '{{ project_name }}.views.home', name='home'),
 
    # url(r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')),
 

	
 
    # Uncomment the admin/doc line below to enable admin documentation:
 
    # 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)