Skip to content

Commit f53eaeb

Browse files
authored
feat: upgrade django to 4.x.x (#7)
1 parent 8413ece commit f53eaeb

4 files changed

Lines changed: 22 additions & 18 deletions

File tree

django_example/settings.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
"""
22
Django settings for django_example project.
33
4-
Generated by 'django-admin startproject' using Django 2.2.1.
4+
Generated by 'django-admin startproject' using Django 4.0.1.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.2/topics/settings/
7+
https://docs.djangoproject.com/en/4.0/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/2.2/ref/settings/
10+
https://docs.djangoproject.com/en/4.0/ref/settings/
1111
"""
1212

13-
import os
13+
from pathlib import Path
1414

15-
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
1717

1818

1919
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = 'un)em+=^3tu@vc+p)04=o!-3%@+*3#f6^syltxlho6n7ee(zq+'
23+
SECRET_KEY = 'django-insecure-5nh*_5n=4g^znmscg315mw1lzpuv=4=vj(pfd-7z7gql^6i#+%'
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
@@ -72,18 +72,18 @@
7272

7373

7474
# Database
75-
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
75+
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
7676

7777
DATABASES = {
7878
'default': {
7979
'ENGINE': 'django.db.backends.sqlite3',
80-
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
80+
'NAME': BASE_DIR / 'db.sqlite3',
8181
}
8282
}
8383

8484

8585
# Password validation
86-
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
86+
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
8787

8888
AUTH_PASSWORD_VALIDATORS = [
8989
{
@@ -102,20 +102,23 @@
102102

103103

104104
# Internationalization
105-
# https://docs.djangoproject.com/en/2.2/topics/i18n/
105+
# https://docs.djangoproject.com/en/4.0/topics/i18n/
106106

107107
LANGUAGE_CODE = 'en-us'
108108

109109
TIME_ZONE = 'UTC'
110110

111111
USE_I18N = True
112112

113-
USE_L10N = True
114-
115113
USE_TZ = True
116114

117115

118116
# Static files (CSS, JavaScript, Images)
119-
# https://docs.djangoproject.com/en/2.2/howto/static-files/
117+
# https://docs.djangoproject.com/en/4.0/howto/static-files/
118+
119+
STATIC_URL = 'static/'
120+
121+
# Default primary key field type
122+
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
120123

121-
STATIC_URL = '/static/'
124+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

django_example/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""django_example URL Configuration
22
33
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/2.2/topics/http/urls/
4+
https://docs.djangoproject.com/en/4.0/topics/http/urls/
55
Examples:
66
Function views
77
1. Add an import: from my_app import views

django_example/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
88
"""
99

1010
import os

manage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
def main():
8+
"""Run administrative tasks."""
89
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_example.settings')
910
try:
1011
from django.core.management import execute_from_command_line

0 commit comments

Comments
 (0)