diff --git a/django_example_euclid/README.md b/django_example_euclid/README.md index 256a0db9a1b1257772e915179c3244ebfafd2ee8..191cd6dcbd194c145f8e9cc6ef2d24fe8297637b 100644 --- a/django_example_euclid/README.md +++ b/django_example_euclid/README.md @@ -2,16 +2,16 @@ Create the anaconda environment for this example - conda create -n euclid_example django + conda create -n orm_django django To activate this environment, use - conda activate euclid_example + conda activate orm_django Additional packages are needed, not available in Anaconda but installed with the `pip` command pip install django-extensions djangorestframework - pip install django-composite-field django-url-filter + pip install django-composite-field django-ufilter To deactivate an active environment, use diff --git a/django_example_euclid/euclid_example/settings.py b/django_example_euclid/euclid_example/settings.py index fea55f83eb2219845ce4b5102364ac94b91cdbc2..c4e7d2c2b9bad4e51f1a74fd2f368cd64bddc4cf 100644 --- a/django_example_euclid/euclid_example/settings.py +++ b/django_example_euclid/euclid_example/settings.py @@ -1,26 +1,26 @@ """ Django settings for euclid_example project. -Generated by 'django-admin startproject' using Django 2.1.1. +Generated by 'django-admin startproject' using Django 4.1. For more information on this file, see -https://docs.djangoproject.com/en/2.1/topics/settings/ +https://docs.djangoproject.com/en/4.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.1/ref/settings/ +https://docs.djangoproject.com/en/4.1/ref/settings/ """ -import os +from pathlib import Path -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '5yu24^zybby@-q_x%ry-nit^!%o8oc2oxmos7d3_d@hf(+qo5k' +SECRET_KEY = 'django-insecure-b=h18+$p+el@nqc+7lb7r^b+@xuo26ip92)pd=-=kjiyty&f@%' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -40,12 +40,13 @@ INSTALLED_APPS = [ 'django_extensions', 'imagedb', 'rest_framework', - 'url_filter', + 'django_ufilter', ] + REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': [ - 'url_filter.integrations.drf.DjangoFilterBackend', + 'django_ufilter.integrations.drf.DRFFilterBackend', ] } @@ -81,18 +82,18 @@ WSGI_APPLICATION = 'euclid_example.wsgi.application' # Database -# https://docs.djangoproject.com/en/2.1/ref/settings/#databases +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -111,7 +112,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ +# https://docs.djangoproject.com/en/4.1/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -119,14 +120,15 @@ TIME_ZONE = 'UTC' USE_I18N = True -USE_L10N = True - USE_TZ = False # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ +# https://docs.djangoproject.com/en/4.1/howto/static-files/ + +STATIC_URL = 'static/' -STATIC_URL = '/static/' +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/django_example_euclid/euclid_example/urls.py b/django_example_euclid/euclid_example/urls.py index 1514eb70da6db7d27f009cd4c94db1cd8a0ade9b..8c2b33b653d8f30271ec90734b024d503849a9a6 100644 --- a/django_example_euclid/euclid_example/urls.py +++ b/django_example_euclid/euclid_example/urls.py @@ -1,7 +1,7 @@ """euclid_example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.1/topics/http/urls/ + https://docs.djangoproject.com/en/4.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views diff --git a/django_example_euclid/euclid_example/wsgi.py b/django_example_euclid/euclid_example/wsgi.py index 0f490d757731eb2fa7ed9c4cdc76b5d27f6fd582..28765b4ff701b10814f2dd6196c1cf3c62de08e3 100644 --- a/django_example_euclid/euclid_example/wsgi.py +++ b/django_example_euclid/euclid_example/wsgi.py @@ -4,7 +4,7 @@ WSGI config for euclid_example 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/2.1/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ """ import os diff --git a/django_example_euclid/imagedb/admin.py b/django_example_euclid/imagedb/admin.py index 0b5aa36ed6adc3265376f484a7c387802ae37496..1447de14e472cec88f7fe795c932e0fd601fbb40 100644 --- a/django_example_euclid/imagedb/admin.py +++ b/django_example_euclid/imagedb/admin.py @@ -1,5 +1,7 @@ from django.contrib import admin +# Register your models here. + from .models import(Instrument, NispDetector, Astrometry, DataContainer, NispRawFrame) diff --git a/django_example_euclid/imagedb/apps.py b/django_example_euclid/imagedb/apps.py index 044a53ae7cd9d67c5d339b9b82e209ba4b80c976..12b4df966c7f0e6a09b5d5c0a72a730bdb13a08f 100644 --- a/django_example_euclid/imagedb/apps.py +++ b/django_example_euclid/imagedb/apps.py @@ -2,4 +2,5 @@ from django.apps import AppConfig class ImagedbConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' name = 'imagedb' diff --git a/django_example_euclid/imagedb/models.py b/django_example_euclid/imagedb/models.py index 7bd48b6d084dd0fbaf125b1b64bc7e212af5a89c..5e81703083a47365bd083118691727dbfb4f40c4 100644 --- a/django_example_euclid/imagedb/models.py +++ b/django_example_euclid/imagedb/models.py @@ -1,10 +1,8 @@ - from django.db import models from composite_field import CompositeField # Create your models here. - IMAGE_CATEGORY = ( 'SCIENCE', 'CALIBRATION', @@ -212,13 +210,3 @@ class NispRawFrame(ImageSpaceFrame): on_delete=models.CASCADE) - - - - - - - - - - diff --git a/django_example_euclid/imagedb/urls.py b/django_example_euclid/imagedb/urls.py index 50f0483c586419f59ad16d3f98bb5f6337540b2d..271c85c4c3c789b08a5ac172c73019feeb7c42ad 100644 --- a/django_example_euclid/imagedb/urls.py +++ b/django_example_euclid/imagedb/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url, include +from django.urls import re_path, include from rest_framework.routers import DefaultRouter from imagedb import views @@ -9,5 +9,5 @@ router.register(r'nisprawframes', views.NispRawFrameViewSet) router.register(r'nispdetectors', views.NispDetectorViewSet) urlpatterns = [ - url(r'^', include(router.urls)) + re_path(r'^', include(router.urls)) ] diff --git a/django_example_euclid/imagedb/views.py b/django_example_euclid/imagedb/views.py index 102311343808b16e6744f04cd69a842eb8d7c4d3..55f20d256b052da5744201b04b31f0b2b53bae5b 100644 --- a/django_example_euclid/imagedb/views.py +++ b/django_example_euclid/imagedb/views.py @@ -1,8 +1,11 @@ +from django.shortcuts import render + +# Create your views here. from rest_framework import viewsets from imagedb.serializers import InstrumentSerializer, NispDetectorSerializer, NispRawFrameSerializer from imagedb.models import Instrument, NispDetector, NispRawFrame -from url_filter.filtersets import ModelFilterSet +from django_ufilter.filtersets import ModelFilterSet class InstrumentViewSet(viewsets.ReadOnlyModelViewSet): @@ -29,4 +32,3 @@ class NispRawFrameViewSet(viewsets.ReadOnlyModelViewSet): - diff --git a/django_example_euclid/manage.py b/django_example_euclid/manage.py index 09333b0048fcf6ba6351e24849bee371ca192a54..7d9fbe43e2041179b47760d2d1b82bca0fb2b0a0 100755 --- a/django_example_euclid/manage.py +++ b/django_example_euclid/manage.py @@ -1,8 +1,11 @@ #!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" import os import sys -if __name__ == '__main__': + +def main(): + """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'euclid_example.settings') try: from django.core.management import execute_from_command_line @@ -13,3 +16,7 @@ if __name__ == '__main__': "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/django_example_insurance/README.md b/django_example_insurance/README.md index 790e976f256d31eed7718fe409c7c91f992f959a..43b807c42d122ca35db96dcc7939a07c0d23cf49 100644 --- a/django_example_insurance/README.md +++ b/django_example_insurance/README.md @@ -10,8 +10,7 @@ To activate this environment, use Additional packages are needed, not available in Anaconda but installed with the `pip` command - pip install django-extensions djangorestframework - pip install django-composite-field django-url-filter + pip install django-extensions pip install django-phonenumber-field phonenumbers pip install Pillow