mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
Updated example app to django 1.8, added migrations
This commit is contained in:
parent
2c123af788
commit
84aa49c698
6 changed files with 150 additions and 105 deletions
20
example/cheeseshop/apps/catalog/migrations/0001_initial.py
Normal file
20
example/cheeseshop/apps/catalog/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Brand',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=75)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
0
example/cheeseshop/apps/catalog/migrations/__init__.py
Normal file
0
example/cheeseshop/apps/catalog/migrations/__init__.py
Normal file
33
example/cheeseshop/apps/storage/migrations/0001_initial.py
Normal file
33
example/cheeseshop/apps/storage/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Shelf',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=75)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name_plural': 'shelves',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Supply',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=75)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name_plural': 'supplies',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
0
example/cheeseshop/apps/storage/migrations/__init__.py
Normal file
0
example/cheeseshop/apps/storage/migrations/__init__.py
Normal file
|
|
@ -1,77 +1,76 @@
|
||||||
from datetime import datetime
|
"""
|
||||||
|
Django settings for cheeseshop project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 1.8.14.
|
||||||
|
|
||||||
|
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/
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
import os
|
||||||
|
from datetime import date
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
# Django settings for cheeseshop project.
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
DEBUG = True
|
|
||||||
TEMPLATE_DEBUG = DEBUG
|
|
||||||
|
|
||||||
ADMINS = (
|
# Quick-start development settings - unsuitable for production
|
||||||
# ('Your Name', 'your_email@domain.com'),
|
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
|
||||||
'NAME': '/tmp/cheeseshop.db', # Or path to database file if using sqlite3.
|
|
||||||
'USER': '', # Not used with sqlite3.
|
|
||||||
'PASSWORD': '', # Not used with sqlite3.
|
|
||||||
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
|
|
||||||
'PORT': '', # Set to empty string for default. Not used with sqlite3.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# On Unix systems, a value of None will cause Django to use the same
|
|
||||||
# timezone as the operating system.
|
|
||||||
# If running in a Windows environment this must be set to the same as your
|
|
||||||
# system time zone.
|
|
||||||
TIME_ZONE = 'America/Chicago'
|
|
||||||
|
|
||||||
# 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
|
SITE_ID = 1
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# Absolute path to the directory that holds media.
|
|
||||||
# Example: "/home/media/media.lawrence.com/"
|
|
||||||
MEDIA_ROOT = ''
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash if there is a path component (optional in other cases).
|
|
||||||
# Examples: "http://media.lawrence.com", "http://example.com/media/"
|
|
||||||
MEDIA_URL = ''
|
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
|
||||||
|
|
||||||
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://foo.com/media/", "/media/".
|
|
||||||
ADMIN_MEDIA_PREFIX = '/media/'
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
SECRET_KEY = 'hdx64#m+lnc_0ffoyehbk&7gk1&*9uar$pcfcm-%$km#p0$k=6'
|
SECRET_KEY = 'hdx64#m+lnc_0ffoyehbk&7gk1&*9uar$pcfcm-%$km#p0$k=6'
|
||||||
|
|
||||||
# List of callables that know how to import templates from various sources.
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
TEMPLATE_LOADERS = (
|
DEBUG = True
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
ALLOWED_HOSTS = []
|
||||||
# 'django.template.loaders.eggs.Loader',
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = (
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.sites',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'cheeseshop.apps.catalog',
|
||||||
|
'cheeseshop.apps.storage',
|
||||||
|
'constance',
|
||||||
|
'constance.backends.database',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
old_INSTALLED_APPS = (
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.sites',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.admin',
|
||||||
|
'cheeseshop.apps.catalog',
|
||||||
|
'cheeseshop.apps.storage',
|
||||||
|
'constance',
|
||||||
|
'constance.backends.database',
|
||||||
|
)
|
||||||
|
|
||||||
|
MIDDLEWARE_CLASSES = (
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
)
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'cheeseshop.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
|
@ -88,35 +87,19 @@ TEMPLATES = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
WSGI_APPLICATION = 'cheeseshop.wsgi.application'
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
)
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'cheeseshop.urls'
|
|
||||||
|
|
||||||
TEMPLATE_DIRS = (
|
# Database
|
||||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
DATABASES = {
|
||||||
'django.contrib.auth',
|
'default': {
|
||||||
'django.contrib.contenttypes',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'django.contrib.sessions',
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||||
'django.contrib.sites',
|
'NAME': '/tmp/cheeseshop.db',
|
||||||
'django.contrib.messages',
|
}
|
||||||
# Uncomment the next line to enable the admin:
|
}
|
||||||
'django.contrib.admin',
|
|
||||||
'cheeseshop.apps.catalog',
|
|
||||||
'cheeseshop.apps.storage',
|
|
||||||
'constance',
|
|
||||||
'constance.backends.database',
|
|
||||||
)
|
|
||||||
|
|
||||||
CONSTANCE_REDIS_CONNECTION = {
|
CONSTANCE_REDIS_CONNECTION = {
|
||||||
'host': 'localhost',
|
'host': 'localhost',
|
||||||
|
|
@ -128,7 +111,7 @@ CONSTANCE_CONFIG = {
|
||||||
'BANNER': ('The National Cheese Emporium', 'name of the shop'),
|
'BANNER': ('The National Cheese Emporium', 'name of the shop'),
|
||||||
'OWNER': ('Mr. Henry Wensleydale', 'owner of the shop'),
|
'OWNER': ('Mr. Henry Wensleydale', 'owner of the shop'),
|
||||||
'MUSICIANS': (4, 'number of musicians inside the shop'),
|
'MUSICIANS': (4, 'number of musicians inside the shop'),
|
||||||
'DATE_ESTABLISHED': (datetime(1972, 11, 30), "the shop's first opening"),
|
'DATE_ESTABLISHED': (date(1972, 11, 30), "the shop's first opening"),
|
||||||
}
|
}
|
||||||
|
|
||||||
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
|
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
|
||||||
|
|
@ -141,3 +124,22 @@ CACHES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CONSTANCE_DATABASE_CACHE_BACKEND = 'default'
|
CONSTANCE_DATABASE_CACHE_BACKEND = 'default'
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
|
TIME_ZONE = 'America/Chicago'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
from django.conf.urls import *
|
from django.conf.urls import include, url
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
# Uncomment the next two lines to enable the admin:
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.conf import settings
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = [
|
||||||
# Example:
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
# (r'^cheeseshop/', include('cheeseshop.foo.urls')),
|
]
|
||||||
|
|
||||||
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
|
|
||||||
# to INSTALLED_APPS to enable admin documentation:
|
|
||||||
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
|
||||||
|
|
||||||
# Uncomment the next line to enable the admin:
|
|
||||||
(r'^admin/', include(admin.site.urls)),
|
|
||||||
)
|
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += staticfiles_urlpatterns()
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue