diff --git a/djangosample/asgi.py b/djangosample/asgi.py new file mode 100644 index 0000000..489cfcd --- /dev/null +++ b/djangosample/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for djangosample project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangosample.settings') + +application = get_asgi_application() diff --git a/djangosample/settings.py b/djangosample/settings.py index 172def6..14df2de 100644 --- a/djangosample/settings.py +++ b/djangosample/settings.py @@ -1,13 +1,13 @@ """ Django settings for djangosample project. -Generated by 'django-admin startproject' using Django 1.10.6. +Generated by 'django-admin startproject' using Django 4.0. For more information on this file, see -https://docs.djangoproject.com/en/1.10/topics/settings/ +https://docs.djangoproject.com/en/4.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/4.0/ref/settings/ """ import os @@ -17,7 +17,7 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '7ngkdjajhzi2oi+6izsv+!hg5lhdhzb0(d8d(qv11$i=)14n*)') @@ -71,7 +71,7 @@ # Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases DATABASES = { 'default': { @@ -86,7 +86,7 @@ # Password validation -# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -105,7 +105,7 @@ # Internationalization -# https://docs.djangoproject.com/en/1.10/topics/i18n/ +# https://docs.djangoproject.com/en/4.0/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -119,10 +119,15 @@ # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.10/howto/static-files/ +# https://docs.djangoproject.com/en/4.0/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = '/app/static/' +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + if DEBUG: ALLOWED_HOSTS += ['*', ] diff --git a/djangosample/urls.py b/djangosample/urls.py index c48d247..300e138 100644 --- a/djangosample/urls.py +++ b/djangosample/urls.py @@ -1,21 +1,21 @@ """djangosample 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/4.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.urls import re_path from django.contrib import admin urlpatterns = [ - url(r'^admin/', admin.site.urls), + re_path(r'^admin/', admin.site.urls), ] diff --git a/djangosample/wsgi.py b/djangosample/wsgi.py index 03f854f..aa1e698 100644 --- a/djangosample/wsgi.py +++ b/djangosample/wsgi.py @@ -4,7 +4,7 @@ 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/4.0/howto/deployment/wsgi/ """ import os diff --git a/manage.py b/manage.py index 398a3f0..07c80e2 100755 --- a/manage.py +++ b/manage.py @@ -6,17 +6,10 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangosample.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)