Changeset - 3ad753235b83
[Not reviewed]
10 1 10
Branko Majic (branko) - 9 years ago 2016-10-18 22:36:06
branko@majic.rs
MDT-3: Renamed existing project template directory so it clearly identifies it belongs to Django 1.8. Replaced the existing project template for Django 1.8 with new, simplified and improved version.
15 files changed with 199 insertions and 226 deletions:
0 comments (0 inline, 0 general)
docs/development.rst
Show inline comments
 
@@ -195,18 +195,19 @@ This is just a rough outline of what needs to be done.
 
       STATIC_URL = '/static/'
 
       MEDIA_URL = '/media/'
 

	
 
       # Absolute filesystem path to directory that will hold user-uploaded
 
       # files.
 
       # Directory for storing and serving user-uploaded files.
 
       MEDIA_ROOT = os.path.normpath(os.path.join(ASSETS_ROOT, "media"))
 

	
 
       # Absolute filesystem path to directory that will hold static files.
 
       # Directory for storing and serving static files.
 
       STATIC_ROOT = os.path.normpath(os.path.join(ASSETS_ROOT, "static"))
 

	
 
       # Additional locations for static files. Useful for project-wide overrides of
 
       # default static files.
 
       # Additional directories from which to read the static files. This can be
 
       # used for overriding application static files on project basis.
 
       STATICFILES_DIRS = (
 
           os.path.normpath(os.path.join(BASE_DIR, "static")),
 
       )
 
   - Update remaining Python files. You may want to template things like
 
     documentation version, Django version etc.
 

	
 
9. At this point you need to be a bit more creative. Depending on Django
 
   version, you may need to isolate different settings to be part of the base
project-django-1.8/manage.py
Show inline comments
 
file renamed from project/manage.py to project-django-1.8/manage.py
project-django-1.8/project_name/__init__.py
Show inline comments
 
file renamed from project/project_name/__init__.py to project-django-1.8/project_name/__init__.py
project-django-1.8/project_name/settings/__init__.py
Show inline comments
 
file renamed from project/project_name/settings/__init__.py to project-django-1.8/project_name/settings/__init__.py
project-django-1.8/project_name/settings/base.py
Show inline comments
 
file renamed from project/project_name/settings/base.py to project-django-1.8/project_name/settings/base.py
 
# Common Django settings for all environments for project {{ project_name }}.
 

	
 
#
 
# This file contains common settings shared amongst all environments of a
 
# project. Do not put any environment-specific settings here.
 
# Base settings for Django project {{ project_name }}. These settings are shared
 
# across all environments.
 
#
 
# Project created from template using Django {{ django_version }}. 
 
#
 
# In order to specify environment-specific settings, use files:
 
#
 
# development.py
 
# testing.py
 
# staging.py
 
# production.py
 
#
 
# For more information on this file see
 
# https://docs.djangoproject.com/en/1.8/topics/settings/
 
#
 
# For the full list of settings and their values, see
 
# https://docs.djangoproject.com/en/1.8/ref/settings/
 

	
 

	
 
# Base paths for accessing project root directory and directory where assets are
 
# stored. Other paths can be built relative to these directories with:
 
# os.path.join(BASE_DIR, ...)
 
# os.path.join(ASSETS_DIR, ...)
 
import os
 

	
 
# Determine the root and assets project directories.
 
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
ASSETS_ROOT = os.path.normpath(os.path.join(PROJECT_ROOT, "assets"))
 
# 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"))
 

	
 
# Applications installed in the project.
 
# List of installed applications.
 
INSTALLED_APPS = (
 
    'django.contrib.admin',
 
    'django.contrib.auth',
 
@@ -21,7 +38,7 @@ INSTALLED_APPS = (
 
    'django.contrib.staticfiles',
 
)
 

	
 
# Middleware classes enabled in the project.
 
# List of middleware classes to apply to incoming requests.
 
MIDDLEWARE_CLASSES = (
 
    'django.contrib.sessions.middleware.SessionMiddleware',
 
    'django.middleware.common.CommonMiddleware',
 
@@ -33,10 +50,10 @@ MIDDLEWARE_CLASSES = (
 
    'django.middleware.security.SecurityMiddleware',
 
)
 

	
 
# URL configuration for the project.
 
# URL configuration to use for serving project root.
 
ROOT_URLCONF = '{{ project_name }}.urls'
 

	
 
# Templates configuration for the project.
 
# Template lookup and rendering configuration.
 
TEMPLATES = [
 
    {
 
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
 
@@ -53,11 +70,15 @@ TEMPLATES = [
 
    },
 
]
 

	
 
# Python dotted path to the WSGI application used by Django's runserver command.
 
# WSGI application module for running the project.
 
WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
 

	
 
# Language, internationalisation, and time configuration
 
# Language, internationalisation, and time configuration.
 
#
 
# For details see
 
# https://docs.djangoproject.com/en/1.8/topics/i18n/
 
LANGUAGE_CODE = 'en-us'
 
TIME_ZONE = 'Europe/Stockholm'
 
USE_I18N = True
 
USE_L10N = True
 
USE_TZ = True
 
@@ -66,16 +87,14 @@ USE_TZ = True
 
STATIC_URL = '/static/'
 
MEDIA_URL = '/media/'
 

	
 
# Absolute filesystem path to the directory that will hold user-uploaded
 
# files. Calculated based on assets root.
 
# Directory for storing and serving user-uploaded files.
 
MEDIA_ROOT = os.path.normpath(os.path.join(ASSETS_ROOT, "media"))
 

	
 
# Absolute path to the directory static files should be collected to. Calculated
 
# based on project assets root.
 
# Directory for storing and serving static files.
 
STATIC_ROOT = os.path.normpath(os.path.join(ASSETS_ROOT, "static"))
 

	
 
# Additional locations for static files. Useful for project-wide overrides of
 
# default static files.
 
# Additional directories from which to read the static files. This can be
 
# used for overriding application static files on project basis.
 
STATICFILES_DIRS = (
 
    os.path.normpath(os.path.join(PROJECT_ROOT, "static")),
 
    os.path.normpath(os.path.join(BASE_DIR, "static")),
 
)
project-django-1.8/project_name/settings/development.py
Show inline comments
 
new file 100644
 
# Development environment settings for project {{ project_name }}.
 

	
 
# Import the base settings.
 
from .base import *
 

	
 
# Credentials in development environment are static.
 
SECRET_KEY="{{ secret_key }}"
 

	
 
# Enable debugging in development environment.
 
DEBUG = True
 
for template_config in TEMPLATES:
 
    template_config['OPTIONS']['debug']=True
 

	
 
# Site administrators and managers.
 
ADMINS = (
 
    # ('Your Name', 'your_email@example.com'),
 
)
 
MANAGERS = ADMINS
 

	
 
# Use SQLite3 for simplicity in development environment.
 
DATABASES = {
 
    'default': {
 
        'ENGINE': 'django.db.backends.sqlite3',
 
        'NAME': 'development.sqlite3',
 
        'USER': '',
 
        'PASSWORD': '',
 
        'HOST': '',
 
        'PORT': '',
 
    }
 
}
project-django-1.8/project_name/settings/production.py
Show inline comments
 
new file 100644
 
# Production environment settings for project {{ project_name }}.
 

	
 
# Import the base settings.
 
from .base import *
 

	
 
# Import credentials.
 
try:
 
    from .credentials import DATABASE_PASSWORD
 
except ImportError:
 
    raise ImproperlyConfigured("Please configure DATABASE_PASSWORD in credentials.py.")
 

	
 
try:
 
    from .credentials import SECRET_KEY
 
except ImportError:
 
    raise ImproperlyConfigured("Please configure SECRET_KEY in credentials.py.")
 

	
 
# Disable debugging.
 
DEBUG = False
 
for template_config in TEMPLATES:
 
    template_config['OPTIONS']['debug']=False
 

	
 
# Site administrators and managers.
 
ADMINS = (
 
    # ('Your Name', 'your_email@example.com'),
 
)
 
MANAGERS = ADMINS
 

	
 
# Database configuration.
 
DATABASES = {
 
    'default': {
 
        'ENGINE': 'django.db.backends.mysql',
 
        'NAME': '{{ project_name }}',
 
        'USER': '{{ project_name }}',
 
        'PASSWORD': DATABASE_PASSWORD,
 
        'HOST': '127.0.0.1',
 
        'PORT': '',
 
    }
 
}
 

	
 
# Hostnames/FQDNs considered valid for accessing the installation.
 
ALLOWED_HOSTS = []
project-django-1.8/project_name/settings/staging.py
Show inline comments
 
new file 100644
 
# Staging environment settings for project {{ project_name }}.
 

	
 
# Import the base settings.
 
from .base import *
 

	
 
# Import credentials.
 
try:
 
    from .credentials import DATABASE_PASSWORD
 
except ImportError:
 
    raise ImproperlyConfigured("Please configure DATABASE_PASSWORD in credentials.py.")
 

	
 
try:
 
    from .credentials import SECRET_KEY
 
except ImportError:
 
    raise ImproperlyConfigured("Please configure SECRET_KEY in credentials.py.")
 

	
 
# Disable debugging.
 
DEBUG = False
 
for template_config in TEMPLATES:
 
    template_config['OPTIONS']['debug']=False
 

	
 
# Site administrators and managers.
 
ADMINS = (
 
    # ('Your Name', 'your_email@example.com'),
 
)
 
MANAGERS = ADMINS
 

	
 
# Database configuration.
 
DATABASES = {
 
    'default': {
 
        'ENGINE': 'django.db.backends.mysql',
 
        'NAME': '{{ project_name }}',
 
        'USER': '{{ project_name }}',
 
        'PASSWORD': DATABASE_PASSWORD,
 
        'HOST': '127.0.0.1',
 
        'PORT': '',
 
    }
 
}
 

	
 
# Hostnames/FQDNs considered valid for accessing the installation.
 
ALLOWED_HOSTS = []
project-django-1.8/project_name/settings/testing.py
Show inline comments
 
new file 100644
 
# Testing environment settings for project {{ project_name }}.
 

	
 
# Import the base settings.
 
from .base import *
 

	
 
# Import credentials.
 
try:
 
    from .credentials import DATABASE_PASSWORD
 
except ImportError:
 
    raise ImproperlyConfigured("Please configure DATABASE_PASSWORD in credentials.py.")
 

	
 
try:
 
    from .credentials import SECRET_KEY
 
except ImportError:
 
    raise ImproperlyConfigured("Please configure SECRET_KEY in credentials.py.")
 

	
 
# Disable debugging.
 
DEBUG = False
 
for template_config in TEMPLATES:
 
    template_config['OPTIONS']['debug']=False
 

	
 
# Site administrators and managers.
 
ADMINS = (
 
    # ('Your Name', 'your_email@example.com'),
 
)
 
MANAGERS = ADMINS
 

	
 
# Database configuration.
 
DATABASES = {
 
    'default': {
 
        'ENGINE': 'django.db.backends.mysql',
 
        'NAME': '{{ project_name }}',
 
        'USER': '{{ project_name }}',
 
        'PASSWORD': DATABASE_PASSWORD,
 
        'HOST': '127.0.0.1',
 
        'PORT': '',
 
    }
 
}
 

	
 
# Hostnames/FQDNs considered valid for accessing the installation.
 
ALLOWED_HOSTS = []
project-django-1.8/project_name/urls.py
Show inline comments
 
file renamed from project/project_name/urls.py to project-django-1.8/project_name/urls.py
 
@@ -10,8 +10,7 @@ Class-based views
 
    1. Add an import:  from other_app.views import Home
 
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
 
Including another URLconf
 
    1. Add an import:  from blog import urls as blog_urls
 
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
 
    1. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
 
"""
 
from django.conf.urls import include, url
 
from django.contrib import admin
project-django-1.8/project_name/wsgi.py
Show inline comments
 
file renamed from project/project_name/wsgi.py to project-django-1.8/project_name/wsgi.py
project/project_name/settings/development.py
Show inline comments
 
deleted file
project/project_name/settings/production.py
Show inline comments
 
deleted file
project/project_name/settings/sample_credentials.py
Show inline comments
 
deleted file
project/project_name/settings/testing.py
Show inline comments
 
deleted file
0 comments (0 inline, 0 general)