Adjust settings to silence warnings

This commit is contained in:
Drew Hubl 2016-09-22 11:16:41 -06:00
parent 0a906b944e
commit 67e47d24a8
5 changed files with 118 additions and 39 deletions

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-09-22 16:56
from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Book',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('categories', multiselectfield.db.fields.MultiSelectField(choices=[(1, 'Handbooks and manuals by discipline'), (2, 'Business books'), (3, 'Books of literary criticism'), (4, 'Books about literary theory'), (5, 'Books about literature')], default=1, max_length=9)),
('tags', multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('sex', 'Sex'), ('work', 'Work'), ('happy', 'Happy'), ('food', 'Food'), ('field', 'Field'), ('boring', 'Boring'), ('interesting', 'Interesting'), ('huge', 'huge'), ('nice', 'Nice')], max_length=54, null=True)),
],
),
]

View file

View file

@ -14,12 +14,27 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
from django import VERSION
try:
from django.conf.urls import include, patterns, url
from django.conf.urls import url
# Compatibility for Django > 1.8
def patterns(prefix, *args):
if VERSION < (1, 9):
from django.conf.urls import patterns as django_patterns
return django_patterns(prefix, *args)
elif prefix != '':
raise NotImplementedError("You need to update your URLConf for "
"Django 1.10, or tweak it to remove the "
"prefix parameter")
else:
return list(args)
except ImportError: # Django < 1.4
from django.conf.urls.defaults import include, patterns, url
from django.conf.urls.defaults import patterns, url
from .views import app_index
urlpatterns = patterns('app.views',
url(r'^$', 'app_index', name='app_index'),
urlpatterns = patterns('',
url(r'^$', app_index, name='app_index'),
)

View file

@ -18,8 +18,9 @@
import os
from os import path
from django import VERSION
DEBUG = True
TEMPLATE_DEBUG = DEBUG
BASE_DIR = path.dirname(path.abspath(__file__))
@ -105,13 +106,6 @@ STATICFILES_FINDERS = (
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'lwfo1o9r^+x8xwec=6$a&m(dmg$1t%8)g6hr%&b4%)%_ualb8s'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@ -127,22 +121,57 @@ ROOT_URLCONF = 'example.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'example.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
if VERSION < (1, 8):
TEMPLATE_DEBUG = DEBUG
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.tz',
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.tz',
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
)
else:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.tz',
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
],
'debug': DEBUG,
'loaders': [
# List of callables that know how to import templates from
# various sources.
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]
},
}
]
INSTALLED_APPS = (
'django.contrib.auth',
@ -198,10 +227,7 @@ LOGGING = {
}
}
import django
if django.VERSION[0] == 1 and django.VERSION[1] >= 4:
TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.tz',)
if VERSION >= (1, 4):
LOGGING['filters'] = {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
@ -209,5 +235,5 @@ if django.VERSION[0] == 1 and django.VERSION[1] >= 4:
}
LOGGING['handlers']['mail_admins']['filters'] = ['require_debug_false']
if django.VERSION >= (1, 6):
if VERSION >= (1, 6):
TEST_RUNNER = 'django.test.runner.DiscoverRunner'

View file

@ -14,14 +14,27 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
from django import VERSION
from django.conf import settings
try:
from django.conf.urls import include, patterns, url
from django.conf.urls import include, url
# Compatibility for Django > 1.8
def patterns(prefix, *args):
if VERSION < (1, 9):
from django.conf.urls import patterns as django_patterns
return django_patterns(prefix, *args)
elif prefix != '':
raise NotImplementedError("You need to update your URLConf for "
"Django 1.10, or tweak it to remove the "
"prefix parameter")
else:
return list(args)
except ImportError: # Django < 1.4
from django.conf.urls.defaults import include, patterns, url
from django.contrib import admin
from django.views.static import serve
admin.autodiscover()
@ -30,13 +43,12 @@ js_info_dict = {
}
urlpatterns = patterns('',
url(r'^', include('example.app.urls')),
url(r'^', include('app.urls')),
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('',
(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:],
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT,
'show_indexes': True}),
url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:],
serve,
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
)