Fixed deprecation warnings in urls from django1.9. Switched to new TEMPLATES setting.

This commit is contained in:
Griatch 2016-02-20 10:42:28 +01:00
parent 26c99f1ece
commit 9bf09365d2
4 changed files with 52 additions and 36 deletions

View file

@ -86,14 +86,27 @@ STATICFILES_DIRS = (
os.path.join(EVENNIA_DIR, "web", "website", "static"),) os.path.join(EVENNIA_DIR, "web", "website", "static"),)
# We setup the location of the website template as well as the admin site. # We setup the location of the website template as well as the admin site.
TEMPLATE_DIRS = ( TEMPLATES = [{
os.path.join(GAME_DIR, "web", "template_overrides", WEBSITE_TEMPLATE), 'BACKEND': 'django.template.backends.django.DjangoTemplates',
os.path.join(GAME_DIR, "web", "template_overrides", WEBCLIENT_TEMPLATE), 'DIRS': [
os.path.join(GAME_DIR, "web", "template_overrides"), os.path.join(GAME_DIR, "web", "template_overrides", WEBSITE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "website", "templates", WEBSITE_TEMPLATE), os.path.join(GAME_DIR, "web", "template_overrides", WEBCLIENT_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "website", "templates"), os.path.join(GAME_DIR, "web", "template_overrides"),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates", WEBCLIENT_TEMPLATE), os.path.join(EVENNIA_DIR, "web", "website", "templates", WEBSITE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates"),) os.path.join(EVENNIA_DIR, "web", "website", "templates"),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates", WEBCLIENT_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates")],
'APP_DIRS': True,
'OPTIONS': {
"context_processors": [
'django.template.context_processors.i18n',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.media',
'django.template.context_processors.debug',
'evennia.web.utils.general_context.general_context']
}
}]
# The secret key is randomly seeded upon creation. It is used to sign # The secret key is randomly seeded upon creation. It is used to sign
# Django's cookies. Do not share this with anyone. Changing it will # Django's cookies. Do not share this with anyone. Changing it will

View file

@ -597,19 +597,28 @@ STATICFILES_IGNORE_PATTERNS = ('README.md',)
WEBSITE_TEMPLATE = 'website' WEBSITE_TEMPLATE = 'website'
WEBCLIENT_TEMPLATE = 'webclient' WEBCLIENT_TEMPLATE = 'webclient'
# We setup the location of the website template as well as the admin site. # We setup the location of the website template as well as the admin site.
TEMPLATE_DIRS = ( TEMPLATES = [{
os.path.join(GAME_DIR, "web", "template_overrides", WEBSITE_TEMPLATE), 'BACKEND': 'django.template.backends.django.DjangoTemplates',
os.path.join(GAME_DIR, "web", "template_overrides", WEBCLIENT_TEMPLATE), 'DIRS': [
os.path.join(GAME_DIR, "web", "template_overrides"), os.path.join(GAME_DIR, "web", "template_overrides", WEBSITE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "website", "templates", WEBSITE_TEMPLATE), os.path.join(GAME_DIR, "web", "template_overrides", WEBCLIENT_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "website", "templates"), os.path.join(GAME_DIR, "web", "template_overrides"),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates", WEBCLIENT_TEMPLATE), os.path.join(EVENNIA_DIR, "web", "website", "templates", WEBSITE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates"),) os.path.join(EVENNIA_DIR, "web", "website", "templates"),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates", WEBCLIENT_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "webclient", "templates")],
'APP_DIRS': True,
'OPTIONS': {
"context_processors": [
'django.template.context_processors.i18n',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.media',
'django.template.context_processors.debug',
'evennia.web.utils.general_context.general_context']
}
}]
# 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',)
# MiddleWare are semi-transparent extensions to Django's functionality. # MiddleWare are semi-transparent extensions to Django's functionality.
# see http://www.djangoproject.com/documentation/middleware/ for a more detailed # see http://www.djangoproject.com/documentation/middleware/ for a more detailed
# explanation. # explanation.
@ -621,15 +630,6 @@ MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.admindocs.middleware.XViewMiddleware', 'django.contrib.admindocs.middleware.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',) 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',)
# Context processors define context variables, generally for the template
# system to use.
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.media',
'django.core.context_processors.debug',
'evennia.web.utils.general_context.general_context',)
###################################################################### ######################################################################
# Evennia components # Evennia components

View file

@ -3,6 +3,7 @@ This structures the (simple) structure of the
webpage 'application'. webpage 'application'.
""" """
from django.conf.urls import * from django.conf.urls import *
from evennia.web.webclient import views as webclient_views
urlpatterns = [ urlpatterns = [
url(r'^$', 'evennia.web.webclient.views.webclient', name="index")] url(r'^$', webclient_views.webclient, name="index")]

View file

@ -5,6 +5,8 @@ This structures the website.
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
from django.conf.urls import url, include from django.conf.urls import url, include
from django import views as django_views
from evennia.web.website import views as website_views
# loop over all settings.INSTALLED_APPS and execute code in # loop over all settings.INSTALLED_APPS and execute code in
# files named admin.py in each such app (this will add those # files named admin.py in each such app (this will add those
@ -12,15 +14,15 @@ from django.conf.urls import url, include
admin.autodiscover() admin.autodiscover()
urlpatterns = [ urlpatterns = [
url(r'^$', 'evennia.web.website.views.page_index', name="index"), url(r'^$', website_views.page_index, name="index"),
url(r'^tbi/', 'evennia.web.website.views.to_be_implemented', name='to_be_implemented'), url(r'^tbi/', website_views.to_be_implemented, name='to_be_implemented'),
# User Authentication (makes login/logout url names available) # User Authentication (makes login/logout url names available)
url(r'^authenticate', include('django.contrib.auth.urls')), url(r'^authenticate', include('django.contrib.auth.urls')),
# Django original admin page. Make this URL is always available, whether # Django original admin page. Make this URL is always available, whether
# we've chosen to use Evennia's custom admin or not. # we've chosen to use Evennia's custom admin or not.
url(r'django_admin/', 'evennia.web.website.views.admin_wrapper', name="django_admin"), url(r'django_admin/', website_views.admin_wrapper, name="django_admin"),
# Admin docs # Admin docs
url(r'^admin/doc/', include('django.contrib.admindocs.urls')) url(r'^admin/doc/', include('django.contrib.admindocs.urls'))
@ -29,7 +31,7 @@ urlpatterns = [
if settings.EVENNIA_ADMIN: if settings.EVENNIA_ADMIN:
urlpatterns += [ urlpatterns += [
# Our override for the admin. # Our override for the admin.
url('^admin/$', 'evennia.web.website.views.evennia_admin', name="evennia_admin"), url('^admin/$', website_views.evennia_admin, name="evennia_admin"),
# Makes sure that other admin pages get loaded. # Makes sure that other admin pages get loaded.
url(r'^admin/', include(admin.site.urls))] url(r'^admin/', include(admin.site.urls))]
@ -41,6 +43,6 @@ else:
# test server (this should normally not be needed). # test server (this should normally not be needed).
if settings.SERVE_MEDIA: if settings.SERVE_MEDIA:
urlpatterns.extend([ urlpatterns.extend([
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), url(r'^media/(?P<path>.*)$', django_views.static.serve, {'document_root': settings.MEDIA_ROOT}),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}) url(r'^static/(?P<path>.*)$', django_views.static.serve, {'document_root': settings.STATIC_ROOT})
]) ])