From eb8616c5ba781c33c29f02c9ca60f98b8bbc8d52 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Mon, 5 Feb 2018 12:18:23 +0100 Subject: [PATCH] align project files to Django 2.0 --- .../SqlServerOnDocker/settings.py | 15 ++++++++------- .../SqlServerOnDocker/urls.py | 14 +++++++------- .../SqlServerOnDocker/wsgi.py | 2 +- .../SqlServerOnDocker/manage.py | 19 ++++++------------- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/settings.py b/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/settings.py index 6c666ab4..04990222 100644 --- a/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/settings.py +++ b/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/settings.py @@ -1,13 +1,13 @@ """ Django settings for SqlServerOnDocker project. -Generated by 'django-admin startproject' using Django 1.10.5. +Generated by 'django-admin startproject' using Django 2.0.2. For more information on this file, see -https://docs.djangoproject.com/en/1.10/topics/settings/ +https://docs.djangoproject.com/en/2.0/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.10/ref/settings/ +https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os @@ -17,7 +17,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'd-uguc(o8$i@^ea_+m^tv^_tt7loyf6zf^o3%*ws#zs42_u#(&' @@ -37,7 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'core', + 'core.apps.CoreConfig', ] MIDDLEWARE = [ @@ -73,7 +73,8 @@ WSGI_APPLICATION = 'SqlServerOnDocker.wsgi.application' # Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases +# https://docs.djangoproject.com/en/2.0/ref/settings/#databases + DATABASES = { 'default': { @@ -91,7 +92,7 @@ DATABASES = { # Password validation -# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { diff --git a/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/urls.py b/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/urls.py index 70feab89..9dfae271 100644 --- a/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/urls.py +++ b/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/urls.py @@ -1,21 +1,21 @@ """SqlServerOnDocker URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/1.10/topics/http/urls/ + https://docs.djangoproject.com/en/2.0/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') + 2. Add a URL to urlpatterns: path('', views.home, name='home') 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') + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf - 1. Import the include() function: from django.conf.urls import url, include - 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.conf.urls import url from django.contrib import admin +from django.urls import path urlpatterns = [ - url(r'^admin/', admin.site.urls), + path('admin/', admin.site.urls), ] diff --git a/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/wsgi.py b/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/wsgi.py index 9c8036cd..9a26bfd9 100644 --- a/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/wsgi.py +++ b/samples/development-frameworks/SqlServerOnDocker/SqlServerOnDocker/wsgi.py @@ -4,7 +4,7 @@ WSGI config for SqlServerOnDocker project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ import os diff --git a/samples/development-frameworks/SqlServerOnDocker/manage.py b/samples/development-frameworks/SqlServerOnDocker/manage.py index a23e2708..8583b80d 100755 --- a/samples/development-frameworks/SqlServerOnDocker/manage.py +++ b/samples/development-frameworks/SqlServerOnDocker/manage.py @@ -6,17 +6,10 @@ if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "SqlServerOnDocker.settings") try: from django.core.management import execute_from_command_line - except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - try: - import django - except ImportError: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) - raise + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc execute_from_command_line(sys.argv)