Code Updates for Django 1.8+

This commit is contained in:
Martin Mahner 2016-03-23 14:02:19 +01:00
parent 2595d22b90
commit d2a704c075
4 changed files with 34 additions and 26 deletions

View file

@ -25,7 +25,6 @@ if not os.path.exists(VAR_ROOT):
#==============================================================================
DEBUG = False
TEMPLATE_DEBUG = DEBUG
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
@ -95,15 +94,24 @@ MIDDLEWARE_CLASSES = (
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
'django.core.context_processors.i18n',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
],
},
},
]
INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.sessions',
'mptt',
'gunicorn',
'dpaste',

View file

@ -1,12 +1,10 @@
from django.conf.urls import url, patterns, include
from django.conf.urls import url, include
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^', include('dpaste.urls.dpaste_api')),
url(r'^', include('dpaste.urls.dpaste')),
(r'^i18n/', include('django.conf.urls.i18n')),
)
url(r'^i18n/', include('django.conf.urls.i18n')),
]
# Custom error handlers which load `dpaste/<code>.html` instead of `<code>.html`
handler404 = 'dpaste.views.page_not_found'

View file

@ -1,17 +1,19 @@
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .. import views
L = getattr(settings, 'DPASTE_SLUG_LENGTH', 4)
urlpatterns = patterns('dpaste.views',
url(r'^about/$', 'about', name='dpaste_about'),
urlpatterns = [
url(r'^about/$', views.about, name='dpaste_about'),
url(r'^$', 'snippet_new', name='snippet_new'),
url(r'^diff/$', 'snippet_diff', name='snippet_diff'),
url(r'^history/$', 'snippet_history', name='snippet_history'),
url(r'^delete/$', 'snippet_delete', name='snippet_delete'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/?$' % L, 'snippet_details', name='snippet_details'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/delete/$' % L, 'snippet_delete', name='snippet_delete'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/gist/$' % L, 'snippet_gist', name='snippet_gist'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/raw/?$' % L, 'snippet_details', {'template_name': 'dpaste/snippet_details_raw.html', 'is_raw': True}, name='snippet_details_raw'),
)
url(r'^$', views.snippet_new, name='snippet_new'),
url(r'^diff/$', views.snippet_diff, name='snippet_diff'),
url(r'^history/$', views.snippet_history, name='snippet_history'),
url(r'^delete/$', views.snippet_delete, name='snippet_delete'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/?$' % L, views.snippet_details, name='snippet_details'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/delete/$' % L, views.snippet_delete, name='snippet_delete'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/gist/$' % L, views.snippet_gist, name='snippet_gist'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/raw/?$' % L, views.snippet_details, {'template_name': 'dpaste/snippet_details_raw.html', 'is_raw': True}, name='snippet_details_raw'),
]

View file

@ -2,6 +2,6 @@ from django.conf.urls import patterns, url
from ..views import snippet_api
urlpatterns = patterns('',
urlpatterns = [
url(r'^api/$', snippet_api, name='dpaste_api_create_snippet'),
)
]