From 345a34dccd40f407c97df884024272be489845d4 Mon Sep 17 00:00:00 2001 From: Jorge Date: Thu, 21 Sep 2023 11:09:39 -0400 Subject: [PATCH] Upgrade to Django 4.2.5 and postgres:16 --- chris_backend/config/asgi.py | 2 +- chris_backend/config/settings/common.py | 26 +++++++++++---------- chris_backend/config/settings/local.py | 14 +++++------ chris_backend/config/settings/production.py | 15 ++++++------ chris_backend/config/urls.py | 5 ++-- chris_backend/config/wsgi.py | 4 ++-- docker-compose_dev.yml | 4 ++-- docker-compose_noswift.yml | 4 ++-- make.sh | 2 +- requirements/base.txt | 20 ++++++++-------- requirements/local.txt | 14 +++++------ 11 files changed, 56 insertions(+), 54 deletions(-) diff --git a/chris_backend/config/asgi.py b/chris_backend/config/asgi.py index 925e43d8..789432b0 100755 --- a/chris_backend/config/asgi.py +++ b/chris_backend/config/asgi.py @@ -4,7 +4,7 @@ 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/ +https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ """ import os, sys diff --git a/chris_backend/config/settings/common.py b/chris_backend/config/settings/common.py index 8ee776a9..09fcf8d2 100755 --- a/chris_backend/config/settings/common.py +++ b/chris_backend/config/settings/common.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- """ -Django settings for mysite project. +Django settings for chris_backend project. -Generated by 'django-admin startproject' using Django 4.0. +Generated by 'django-admin startproject' using Django 4.2.5. For more information on this file, see -https://docs.djangoproject.com/en/4.0/topics/settings/ +https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/4.0/ref/settings/ +https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib import Path @@ -105,7 +105,7 @@ # Database -# https://docs.djangoproject.com/en/4.0/ref/settings/#databases +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { 'default': { @@ -115,7 +115,7 @@ # Password validation -# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -134,7 +134,7 @@ # Internationalization -# https://docs.djangoproject.com/en/4.0/topics/i18n/ +# https://docs.djangoproject.com/en/4.2/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -142,23 +142,25 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.0/howto/static-files/ +# https://docs.djangoproject.com/en/4.2/howto/static-files/ STATIC_URL = '/static/' # https://whitenoise.readthedocs.io/en/stable/django.html -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +STORAGES = { + 'staticfiles': { + 'BACKEND': 'whitenoise.storage.CompressedManifestStaticFilesStorage', + }, +} # `./manage.py collectstatic` is run during build STATIC_ROOT = '/opt/app-root/var/staticfiles' # Default primary key field type -# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/chris_backend/config/settings/local.py b/chris_backend/config/settings/local.py index 65c42c72..6b006fd9 100755 --- a/chris_backend/config/settings/local.py +++ b/chris_backend/config/settings/local.py @@ -19,20 +19,20 @@ from django.core.exceptions import ImproperlyConfigured # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'w1kxu^l=@pnsf!5piqz6!!5kdcdpo79y6jebbp+2244yjm*#+k' # Hosts/domain names that are valid for this site -# See https://docs.djangoproject.com/en/4.0/ref/settings/#allowed-hosts +# See https://docs.djangoproject.com/en/4.2/ref/settings/#allowed-hosts ALLOWED_HOSTS = ['*'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True # LOGGING CONFIGURATION -# See https://docs.djangoproject.com/en/4.0/topics/logging/ for +# See https://docs.djangoproject.com/en/4.2/topics/logging/ for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, @@ -87,7 +87,7 @@ if STORAGE_ENV not in ('swift', 'filesystem'): raise ImproperlyConfigured(f"Unsupported value '{STORAGE_ENV}' for STORAGE_ENV") -DEFAULT_FILE_STORAGE = 'swift.storage.SwiftStorage' +STORAGES['default'] = {'BACKEND': 'swift.storage.SwiftStorage'} SWIFT_AUTH_URL = 'http://swift_service:8080/auth/v1.0' # Swift service settings SWIFT_USERNAME = 'chris:chris1234' SWIFT_KEY = 'testing' @@ -97,12 +97,12 @@ 'authurl': SWIFT_AUTH_URL} MEDIA_ROOT = None if STORAGE_ENV == 'filesystem': - DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' + STORAGES['default'] = {'BACKEND': 'django.core.files.storage.FileSystemStorage'} MEDIA_ROOT = '/var/chris' # local filesystem storage settings try: verify_storage_connection( - DEFAULT_FILE_STORAGE=DEFAULT_FILE_STORAGE, + DEFAULT_FILE_STORAGE=STORAGES['default']['BACKEND'], MEDIA_ROOT=MEDIA_ROOT, SWIFT_CONTAINER_NAME=SWIFT_CONTAINER_NAME, SWIFT_CONNECTION_PARAMS=SWIFT_CONNECTION_PARAMS @@ -114,7 +114,7 @@ CHRIS_STORE_URL = 'http://chris-store.local:8010/api/v1/' # Database -# https://docs.djangoproject.com/en/4.0/ref/settings/#databases +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES['default']['NAME'] = 'chris_dev' DATABASES['default']['USER'] = 'chris' DATABASES['default']['PASSWORD'] = 'Chris1234' diff --git a/chris_backend/config/settings/production.py b/chris_backend/config/settings/production.py index 0312e90b..415e6fed 100755 --- a/chris_backend/config/settings/production.py +++ b/chris_backend/config/settings/production.py @@ -30,7 +30,7 @@ def get_secret(setting, secret_type=env): # SECRET CONFIGURATION # ------------------------------------------------------------------------------ -# See: https://docs.djangoproject.com/en/4.0/ref/settings/#secret-key +# See: https://docs.djangoproject.com/en/4.2/ref/settings/#secret-key # Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ SECRET_KEY = get_secret('DJANGO_SECRET_KEY') @@ -38,14 +38,13 @@ def get_secret(setting, secret_type=env): # SITE CONFIGURATION # ------------------------------------------------------------------------------ # Hosts/domain names that are valid for this site -# See https://docs.djangoproject.com/en/4.0/ref/settings/#allowed-hosts +# See https://docs.djangoproject.com/en/4.2/ref/settings/#allowed-hosts ALLOWED_HOSTS = get_secret('DJANGO_ALLOWED_HOSTS', env.list) # END SITE CONFIGURATION # DATABASE CONFIGURATION # ------------------------------------------------------------------------------ -# Raises ImproperlyConfigured exception if DATABASE_URL not set DATABASES['default']['NAME'] = get_secret('POSTGRES_DB') DATABASES['default']['USER'] = get_secret('POSTGRES_USER') DATABASES['default']['PASSWORD'] = get_secret('POSTGRES_PASSWORD') @@ -60,7 +59,7 @@ def get_secret(setting, secret_type=env): raise ImproperlyConfigured(f"Unsupported value '{STORAGE_ENV}' for STORAGE_ENV") if STORAGE_ENV == 'swift': - DEFAULT_FILE_STORAGE = 'swift.storage.SwiftStorage' + STORAGES['default'] = {'BACKEND': 'swift.storage.SwiftStorage'} SWIFT_AUTH_URL = get_secret('SWIFT_AUTH_URL') SWIFT_USERNAME = get_secret('SWIFT_USERNAME') SWIFT_KEY = get_secret('SWIFT_KEY') @@ -69,14 +68,14 @@ def get_secret(setting, secret_type=env): 'key': SWIFT_KEY, 'authurl': SWIFT_AUTH_URL} verify_storage = lambda: verify_storage_connection( - DEFAULT_FILE_STORAGE=DEFAULT_FILE_STORAGE, + DEFAULT_FILE_STORAGE=STORAGES['default']['BACKEND'], SWIFT_CONTAINER_NAME=SWIFT_CONTAINER_NAME, SWIFT_CONNECTION_PARAMS=SWIFT_CONNECTION_PARAMS ) elif STORAGE_ENV == 'filesystem': - DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' + STORAGES['default'] = {'BACKEND': 'django.core.files.storage.FileSystemStorage'} MEDIA_ROOT = get_secret('MEDIA_ROOT') - verify_storage = lambda: verify_storage_connection(DEFAULT_FILE_STORAGE=DEFAULT_FILE_STORAGE, + verify_storage = lambda: verify_storage_connection(DEFAULT_FILE_STORAGE=STORAGES['default']['BACKEND'], MEDIA_ROOT=MEDIA_ROOT) else: verify_storage = lambda: verify_storage_connection() @@ -92,7 +91,7 @@ def get_secret(setting, secret_type=env): # LOGGING CONFIGURATION -# See https://docs.djangoproject.com/en/4.0/topics/logging/ for +# See https://docs.djangoproject.com/en/4.2/topics/logging/ for # more details on how to customize your logging configuration. ADMINS = [('FNNDSC Developers', 'dev@babymri.org')] LOGGING = { diff --git a/chris_backend/config/urls.py b/chris_backend/config/urls.py index c3846c40..9722975b 100755 --- a/chris_backend/config/urls.py +++ b/chris_backend/config/urls.py @@ -1,7 +1,8 @@ -"""chris_backend URL Configuration +""" +URL configuration for chris_backend project. The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.0/topics/http/urls/ + https://docs.djangoproject.com/en/4.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views diff --git a/chris_backend/config/wsgi.py b/chris_backend/config/wsgi.py index fe0ea8a1..4de1837e 100755 --- a/chris_backend/config/wsgi.py +++ b/chris_backend/config/wsgi.py @@ -1,10 +1,10 @@ """ -WSGI config for mysite project. +WSGI config for chris_backend 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/4.0/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ """ import os, sys diff --git a/docker-compose_dev.yml b/docker-compose_dev.yml index c27eb9a5..10291c50 100755 --- a/docker-compose_dev.yml +++ b/docker-compose_dev.yml @@ -182,7 +182,7 @@ services: role: "Backend development periodic tasks scheduler" chris_dev_db: - image: postgres:13 + image: postgres:16 volumes: - chris_dev_db_data:/var/lib/postgresql/data environment: @@ -246,7 +246,7 @@ services: role: "Chris store service" chris_store_db: - image: postgres:13 + image: postgres:16 volumes: - chris_store_db_data:/var/lib/postgresql/data environment: diff --git a/docker-compose_noswift.yml b/docker-compose_noswift.yml index 2dbbabda..3ad96490 100755 --- a/docker-compose_noswift.yml +++ b/docker-compose_noswift.yml @@ -161,7 +161,7 @@ services: role: "Backend development periodic tasks scheduler" chris_dev_db: - image: postgres:13 + image: postgres:16 volumes: - chris_dev_db_data:/var/lib/postgresql/data environment: @@ -214,7 +214,7 @@ services: role: "Chris store service" chris_store_db: - image: postgres:13 + image: postgres:16 volumes: - chris_store_db_data:/var/lib/postgresql/data environment: diff --git a/make.sh b/make.sh index 1e4717c4..ef0aedb3 100755 --- a/make.sh +++ b/make.sh @@ -347,7 +347,7 @@ rm -f dc.out ; title -d 1 "Pulling non-'local/' core containers where needed" printf "${LightCyan}%13s${Green}%-67s${Yellow}\n" \ "$ docker pull" " library/postgres" | ./boxes.sh windowBottom - docker pull postgres:13 >& dc.out + docker pull postgres:16 >& dc.out dc_check $? "PRINT" echo "" | ./boxes.sh printf "${LightCyan}%13s${Green}%-67s${Yellow}\n" \ diff --git a/requirements/base.txt b/requirements/base.txt index 52695206..4a5eb96d 100755 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,15 +1,15 @@ -Django==4.0 -django-filter==22.1 -djangorestframework==3.13.1 -django-cors-headers==3.13.0 -psycopg2==2.9.3 +Django==4.2.5 +django-filter==23.3 +djangorestframework==3.14.0 +django-cors-headers==4.2.0 +psycopg[binary,pool] environs==9.5.0 -python-swiftclient==4.1.0 -django-storage-swift==1.2.19 -celery==5.2.7 -django-celery-beat==2.3.0 +python-swiftclient==4.4.0 +django-storage-swift==1.3.0 +celery==5.3.4 +django-celery-beat==2.5.0 python-chrisstoreclient==1.0.0 python-pfconclient==3.2.0 -django-auth-ldap==4.1.0 +django-auth-ldap==4.5.0 PyYAML==6.0.1 whitenoise[brotli]==6.5.0 diff --git a/requirements/local.txt b/requirements/local.txt index 4ec1abaa..3eec12c9 100755 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -1,11 +1,11 @@ # Local development dependencies go here -r base.txt -django-debug-toolbar==3.6.0 -django-extensions==3.2.0 +django-debug-toolbar==4.2.0 +django-extensions==3.2.3 collection-json==0.1.1 -coverage==6.4.4 -pylint==2.15.0 -flake8==5.0.4 -isort==5.10.1 -pudb>=2019.1 +coverage==7.3.1 +pylint==2.17.5 +flake8==6.1.0 +isort==5.12.0 +pudb==2022.1.3 https://github.com/msbrogli/rpudb/archive/master.zip