Skip to content

Commit f47b631

Browse files
authored
Update to latest versions of django and python3.8 (#17)
1 parent 4783ccc commit f47b631

File tree

8 files changed

+44
-25
lines changed

8 files changed

+44
-25
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Pull a pre-built alpine docker image with nginx and python3 installed
2-
FROM tiangolo/uwsgi-nginx:python3.6-alpine3.7
2+
FROM tiangolo/uwsgi-nginx:python3.8-alpine-2020-12-19
33

44
# Set the port on which the app runs; make both values the same.
55
#

hello/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from datetime import datetime
2-
31
from django.shortcuts import redirect, render
2+
from django.utils.timezone import datetime
43
from django.views.generic import ListView
54

65
from hello.forms import LogMessageForm

manage.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
23
import os
34
import sys
45

5-
if __name__ == '__main__':
6+
7+
def main():
8+
"""Run administrative tasks."""
69
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web_project.settings')
710
try:
811
from django.core.management import execute_from_command_line
@@ -13,3 +16,7 @@
1316
"forget to activate a virtual environment?"
1417
) from exc
1518
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Django>=2.1.2
2-
pytz==2018.5
1+
Django>=3.1.0
2+
pytz==2020.5

web_project/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for web_project project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web_project.settings')
15+
16+
application = get_asgi_application()

web_project/settings.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
"""
22
Django settings for web_project project.
33
4-
Generated by 'django-admin startproject' using Django 2.1.1.
4+
Generated by 'django-admin startproject' using Django 3.1.5.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.1/topics/settings/
7+
https://docs.djangoproject.com/en/3.1/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/2.1/ref/settings/
10+
https://docs.djangoproject.com/en/3.1/ref/settings/
1111
"""
1212

13-
import os
14-
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__)))
13+
from pathlib import Path
1714

15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
1817

1918
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
19+
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
2120

2221
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = '2gult1d96#@#b2%tz+k9x1q%-4(%f@va-!sbv*q&$t^gpp8-_='
22+
SECRET_KEY = '6cskd7@vosz+^h5org$_jjq)l$ai-05q8-g^^$tdb$x*ud7e0='
2423

2524
# SECURITY WARNING: don't run with debug turned on in production!
26-
# If you set to False, also add "localhost" to ALLOWED_HOSTS or else
27-
# you'll get "Bad Request" when running locally.
2825
DEBUG = True
2926

3027
# When deploying to Azure App Service, add you <name>.azurewebsites.net
@@ -81,18 +78,18 @@
8178

8279

8380
# Database
84-
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
81+
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
8582

8683
DATABASES = {
8784
'default': {
8885
'ENGINE': 'django.db.backends.sqlite3',
89-
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
86+
'NAME': BASE_DIR / 'db.sqlite3',
9087
}
9188
}
9289

9390

9491
# Password validation
95-
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
92+
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
9693

9794
AUTH_PASSWORD_VALIDATORS = [
9895
{
@@ -111,7 +108,7 @@
111108

112109

113110
# Internationalization
114-
# https://docs.djangoproject.com/en/2.1/topics/i18n/
111+
# https://docs.djangoproject.com/en/3.1/topics/i18n/
115112

116113
LANGUAGE_CODE = 'en-us'
117114

@@ -125,12 +122,12 @@
125122

126123

127124
# Static files (CSS, JavaScript, Images)
128-
# https://docs.djangoproject.com/en/2.1/howto/static-files/
125+
# https://docs.djangoproject.com/en/3.1/howto/static-files/
129126

130127
STATIC_URL = '/static/'
131128

132129
# The location where the collectstatic command collects static files from apps.
133130
# A dedicated static file server is typically used in production to serve files
134131
# from this location, rather than relying on the app server to serve those files
135132
# from various locations in the app. Doing so results in better overall performance.
136-
STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected')
133+
STATIC_ROOT = BASE_DIR / 'static_collected'

web_project/urls.py

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

web_project/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.1/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
88
"""
99

1010
import os

0 commit comments

Comments
 (0)