From 0eab11568534364b9ae14b6ee08a08f53bf377e5 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:42:36 +0100 Subject: [PATCH 01/10] Django version update Mostly documentation links and minor changes --- django-diary/source_code_final/diary/asgi.py | 2 +- .../source_code_final/diary/settings.py | 24 +++++++++---------- django-diary/source_code_final/diary/urls.py | 18 +++++++++++++- django-diary/source_code_final/diary/wsgi.py | 2 +- .../source_code_final/entries/admin.py | 1 - .../source_code_final/entries/tests.py | 3 +++ django-diary/source_code_step_1/diary/asgi.py | 2 +- .../source_code_step_1/diary/settings.py | 24 +++++++++---------- django-diary/source_code_step_1/diary/urls.py | 6 ++--- django-diary/source_code_step_1/diary/wsgi.py | 2 +- django-diary/source_code_step_2/diary/asgi.py | 2 +- .../source_code_step_2/diary/settings.py | 24 +++++++++---------- django-diary/source_code_step_2/diary/urls.py | 6 ++--- django-diary/source_code_step_2/diary/wsgi.py | 2 +- .../source_code_step_2/entries/admin.py | 1 - .../source_code_step_2/entries/tests.py | 3 +++ .../source_code_step_2/entries/views.py | 4 +++- django-diary/source_code_step_3/diary/asgi.py | 2 +- .../source_code_step_3/diary/settings.py | 24 +++++++++---------- django-diary/source_code_step_3/diary/urls.py | 18 +++++++++++++- django-diary/source_code_step_3/diary/wsgi.py | 2 +- .../source_code_step_3/entries/admin.py | 1 - .../source_code_step_3/entries/views.py | 2 +- django-diary/source_code_step_4/diary/asgi.py | 2 +- .../source_code_step_4/diary/settings.py | 24 +++++++++---------- django-diary/source_code_step_4/diary/urls.py | 18 +++++++++++++- django-diary/source_code_step_4/diary/wsgi.py | 2 +- .../source_code_step_4/entries/admin.py | 1 - .../source_code_step_4/entries/views.py | 2 +- django-diary/source_code_step_5/diary/asgi.py | 2 +- .../source_code_step_5/diary/settings.py | 24 +++++++++---------- django-diary/source_code_step_5/diary/urls.py | 18 +++++++++++++- django-diary/source_code_step_5/diary/wsgi.py | 2 +- .../source_code_step_5/entries/admin.py | 1 - django-diary/source_code_step_6/diary/asgi.py | 2 +- .../source_code_step_6/diary/settings.py | 24 +++++++++---------- django-diary/source_code_step_6/diary/urls.py | 18 +++++++++++++- django-diary/source_code_step_6/diary/wsgi.py | 2 +- .../source_code_step_6/entries/admin.py | 1 - 39 files changed, 193 insertions(+), 125 deletions(-) create mode 100644 django-diary/source_code_final/entries/tests.py create mode 100644 django-diary/source_code_step_2/entries/tests.py diff --git a/django-diary/source_code_final/diary/asgi.py b/django-diary/source_code_final/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_final/diary/asgi.py +++ b/django-diary/source_code_final/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_final/diary/settings.py b/django-diary/source_code_final/diary/settings.py index 3b3d14bcba..89d48bf206 100644 --- a/django-diary/source_code_final/diary/settings.py +++ b/django-diary/source_code_final/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -74,7 +74,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -85,7 +85,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -112,17 +112,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_final/diary/urls.py b/django-diary/source_code_final/diary/urls.py index 7e0dbbe031..9d657419e8 100644 --- a/django-diary/source_code_final/diary/urls.py +++ b/django-diary/source_code_final/diary/urls.py @@ -1,5 +1,21 @@ +""" +URL configuration for diary project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 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: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" from django.contrib import admin -from django.urls import include, path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_final/diary/wsgi.py b/django-diary/source_code_final/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_final/diary/wsgi.py +++ b/django-diary/source_code_final/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_final/entries/admin.py b/django-diary/source_code_final/entries/admin.py index f9de2d78e2..9047611e37 100644 --- a/django-diary/source_code_final/entries/admin.py +++ b/django-diary/source_code_final/entries/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_final/entries/tests.py b/django-diary/source_code_final/entries/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/django-diary/source_code_final/entries/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-diary/source_code_step_1/diary/asgi.py b/django-diary/source_code_step_1/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_step_1/diary/asgi.py +++ b/django-diary/source_code_step_1/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_step_1/diary/settings.py b/django-diary/source_code_step_1/diary/settings.py index 22c75a81ab..7632878adb 100644 --- a/django-diary/source_code_step_1/diary/settings.py +++ b/django-diary/source_code_step_1/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -73,7 +73,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -84,7 +84,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -103,7 +103,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -111,17 +111,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_step_1/diary/urls.py b/django-diary/source_code_step_1/diary/urls.py index 0b35a4c9e1..d71754adf2 100644 --- a/django-diary/source_code_step_1/diary/urls.py +++ b/django-diary/source_code_step_1/diary/urls.py @@ -1,7 +1,8 @@ -"""diary URL Configuration +""" +URL configuration for diary project. The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/topics/http/urls/ + https://docs.djangoproject.com/en/5.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views @@ -13,7 +14,6 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ - from django.contrib import admin from django.urls import path diff --git a/django-diary/source_code_step_1/diary/wsgi.py b/django-diary/source_code_step_1/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_step_1/diary/wsgi.py +++ b/django-diary/source_code_step_1/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_step_2/diary/asgi.py b/django-diary/source_code_step_2/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_step_2/diary/asgi.py +++ b/django-diary/source_code_step_2/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_step_2/diary/settings.py b/django-diary/source_code_step_2/diary/settings.py index 3b3d14bcba..89d48bf206 100644 --- a/django-diary/source_code_step_2/diary/settings.py +++ b/django-diary/source_code_step_2/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -74,7 +74,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -85,7 +85,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -112,17 +112,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_step_2/diary/urls.py b/django-diary/source_code_step_2/diary/urls.py index 0b35a4c9e1..d71754adf2 100644 --- a/django-diary/source_code_step_2/diary/urls.py +++ b/django-diary/source_code_step_2/diary/urls.py @@ -1,7 +1,8 @@ -"""diary URL Configuration +""" +URL configuration for diary project. The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/topics/http/urls/ + https://docs.djangoproject.com/en/5.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views @@ -13,7 +14,6 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ - from django.contrib import admin from django.urls import path diff --git a/django-diary/source_code_step_2/diary/wsgi.py b/django-diary/source_code_step_2/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_step_2/diary/wsgi.py +++ b/django-diary/source_code_step_2/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_step_2/entries/admin.py b/django-diary/source_code_step_2/entries/admin.py index f9de2d78e2..9047611e37 100644 --- a/django-diary/source_code_step_2/entries/admin.py +++ b/django-diary/source_code_step_2/entries/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_2/entries/tests.py b/django-diary/source_code_step_2/entries/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/django-diary/source_code_step_2/entries/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-diary/source_code_step_2/entries/views.py b/django-diary/source_code_step_2/entries/views.py index 68f1f58d06..91ea44a218 100644 --- a/django-diary/source_code_step_2/entries/views.py +++ b/django-diary/source_code_step_2/entries/views.py @@ -1 +1,3 @@ -# Content will be added in the next step +from django.shortcuts import render + +# Create your views here. diff --git a/django-diary/source_code_step_3/diary/asgi.py b/django-diary/source_code_step_3/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_step_3/diary/asgi.py +++ b/django-diary/source_code_step_3/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_step_3/diary/settings.py b/django-diary/source_code_step_3/diary/settings.py index 3b3d14bcba..89d48bf206 100644 --- a/django-diary/source_code_step_3/diary/settings.py +++ b/django-diary/source_code_step_3/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -74,7 +74,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -85,7 +85,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -112,17 +112,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_step_3/diary/urls.py b/django-diary/source_code_step_3/diary/urls.py index 7e0dbbe031..9d657419e8 100644 --- a/django-diary/source_code_step_3/diary/urls.py +++ b/django-diary/source_code_step_3/diary/urls.py @@ -1,5 +1,21 @@ +""" +URL configuration for diary project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 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: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" from django.contrib import admin -from django.urls import include, path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_3/diary/wsgi.py b/django-diary/source_code_step_3/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_step_3/diary/wsgi.py +++ b/django-diary/source_code_step_3/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_step_3/entries/admin.py b/django-diary/source_code_step_3/entries/admin.py index f9de2d78e2..9047611e37 100644 --- a/django-diary/source_code_step_3/entries/admin.py +++ b/django-diary/source_code_step_3/entries/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_3/entries/views.py b/django-diary/source_code_step_3/entries/views.py index 8093802fc8..6063445129 100644 --- a/django-diary/source_code_step_3/entries/views.py +++ b/django-diary/source_code_step_3/entries/views.py @@ -1,6 +1,6 @@ from django.views.generic import ( - DetailView, ListView, + DetailView, ) from .models import Entry diff --git a/django-diary/source_code_step_4/diary/asgi.py b/django-diary/source_code_step_4/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_step_4/diary/asgi.py +++ b/django-diary/source_code_step_4/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_step_4/diary/settings.py b/django-diary/source_code_step_4/diary/settings.py index 3b3d14bcba..89d48bf206 100644 --- a/django-diary/source_code_step_4/diary/settings.py +++ b/django-diary/source_code_step_4/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -74,7 +74,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -85,7 +85,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -112,17 +112,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_step_4/diary/urls.py b/django-diary/source_code_step_4/diary/urls.py index 7e0dbbe031..9d657419e8 100644 --- a/django-diary/source_code_step_4/diary/urls.py +++ b/django-diary/source_code_step_4/diary/urls.py @@ -1,5 +1,21 @@ +""" +URL configuration for diary project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 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: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" from django.contrib import admin -from django.urls import include, path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_4/diary/wsgi.py b/django-diary/source_code_step_4/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_step_4/diary/wsgi.py +++ b/django-diary/source_code_step_4/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_step_4/entries/admin.py b/django-diary/source_code_step_4/entries/admin.py index f9de2d78e2..9047611e37 100644 --- a/django-diary/source_code_step_4/entries/admin.py +++ b/django-diary/source_code_step_4/entries/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_4/entries/views.py b/django-diary/source_code_step_4/entries/views.py index 8093802fc8..6063445129 100644 --- a/django-diary/source_code_step_4/entries/views.py +++ b/django-diary/source_code_step_4/entries/views.py @@ -1,6 +1,6 @@ from django.views.generic import ( - DetailView, ListView, + DetailView, ) from .models import Entry diff --git a/django-diary/source_code_step_5/diary/asgi.py b/django-diary/source_code_step_5/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_step_5/diary/asgi.py +++ b/django-diary/source_code_step_5/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_step_5/diary/settings.py b/django-diary/source_code_step_5/diary/settings.py index 3b3d14bcba..89d48bf206 100644 --- a/django-diary/source_code_step_5/diary/settings.py +++ b/django-diary/source_code_step_5/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -74,7 +74,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -85,7 +85,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -112,17 +112,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_step_5/diary/urls.py b/django-diary/source_code_step_5/diary/urls.py index 7e0dbbe031..9d657419e8 100644 --- a/django-diary/source_code_step_5/diary/urls.py +++ b/django-diary/source_code_step_5/diary/urls.py @@ -1,5 +1,21 @@ +""" +URL configuration for diary project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 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: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" from django.contrib import admin -from django.urls import include, path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_5/diary/wsgi.py b/django-diary/source_code_step_5/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_step_5/diary/wsgi.py +++ b/django-diary/source_code_step_5/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_step_5/entries/admin.py b/django-diary/source_code_step_5/entries/admin.py index f9de2d78e2..9047611e37 100644 --- a/django-diary/source_code_step_5/entries/admin.py +++ b/django-diary/source_code_step_5/entries/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_6/diary/asgi.py b/django-diary/source_code_step_6/diary/asgi.py index d24c6f1cdf..5fac3d04e9 100644 --- a/django-diary/source_code_step_6/diary/asgi.py +++ b/django-diary/source_code_step_6/diary/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/3.2/howto/deployment/asgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ """ import os diff --git a/django-diary/source_code_step_6/diary/settings.py b/django-diary/source_code_step_6/diary/settings.py index 3b3d14bcba..89d48bf206 100644 --- a/django-diary/source_code_step_6/diary/settings.py +++ b/django-diary/source_code_step_6/diary/settings.py @@ -1,13 +1,13 @@ """ Django settings for diary project. -Generated by 'django-admin startproject' using Django 3.2.1. +Generated by 'django-admin startproject' using Django 5.1.4. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -17,11 +17,11 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ( - "django-insecure-kom*7k3n4v3gj_mrcp19r_(rl#v^t2v90i_t2dd9&4*4e1nb%+" + "django-insecure-lxfw6(cjvk39um)u-pot#ri79*14rg_c#1nharb)&l10%5jymv" ) # SECURITY WARNING: don't run with debug turned on in production! @@ -74,7 +74,7 @@ # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { "default": { @@ -85,7 +85,7 @@ # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = "en-us" @@ -112,17 +112,15 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "/static/" +STATIC_URL = "static/" # Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/django-diary/source_code_step_6/diary/urls.py b/django-diary/source_code_step_6/diary/urls.py index 7e0dbbe031..9d657419e8 100644 --- a/django-diary/source_code_step_6/diary/urls.py +++ b/django-diary/source_code_step_6/diary/urls.py @@ -1,5 +1,21 @@ +""" +URL configuration for diary project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 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: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" from django.contrib import admin -from django.urls import include, path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_6/diary/wsgi.py b/django-diary/source_code_step_6/diary/wsgi.py index 6951b16c85..50dd87ea70 100644 --- a/django-diary/source_code_step_6/diary/wsgi.py +++ b/django-diary/source_code_step_6/diary/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/3.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/django-diary/source_code_step_6/entries/admin.py b/django-diary/source_code_step_6/entries/admin.py index f9de2d78e2..9047611e37 100644 --- a/django-diary/source_code_step_6/entries/admin.py +++ b/django-diary/source_code_step_6/entries/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from .models import Entry admin.site.register(Entry) From e8f8beb7addba9e06e036c479b4a9a7e1d2f5671 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:45:04 +0100 Subject: [PATCH 02/10] Run isort --- django-diary/source_code_final/diary/urls.py | 2 +- django-diary/source_code_final/entries/admin.py | 1 + django-diary/source_code_step_2/entries/admin.py | 1 + django-diary/source_code_step_3/diary/urls.py | 2 +- django-diary/source_code_step_3/entries/admin.py | 1 + django-diary/source_code_step_3/entries/tests.py | 3 +++ django-diary/source_code_step_3/entries/views.py | 5 +---- django-diary/source_code_step_4/diary/urls.py | 2 +- django-diary/source_code_step_4/entries/admin.py | 1 + django-diary/source_code_step_4/entries/tests.py | 3 +++ django-diary/source_code_step_4/entries/views.py | 5 +---- django-diary/source_code_step_5/diary/urls.py | 2 +- django-diary/source_code_step_5/entries/admin.py | 1 + django-diary/source_code_step_5/entries/tests.py | 3 +++ django-diary/source_code_step_6/diary/urls.py | 2 +- django-diary/source_code_step_6/entries/admin.py | 1 + django-diary/source_code_step_6/entries/tests.py | 3 +++ 17 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 django-diary/source_code_step_3/entries/tests.py create mode 100644 django-diary/source_code_step_4/entries/tests.py create mode 100644 django-diary/source_code_step_5/entries/tests.py create mode 100644 django-diary/source_code_step_6/entries/tests.py diff --git a/django-diary/source_code_final/diary/urls.py b/django-diary/source_code_final/diary/urls.py index 9d657419e8..019b0efada 100644 --- a/django-diary/source_code_final/diary/urls.py +++ b/django-diary/source_code_final/diary/urls.py @@ -15,7 +15,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_final/entries/admin.py b/django-diary/source_code_final/entries/admin.py index 9047611e37..f9de2d78e2 100644 --- a/django-diary/source_code_final/entries/admin.py +++ b/django-diary/source_code_final/entries/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_2/entries/admin.py b/django-diary/source_code_step_2/entries/admin.py index 9047611e37..f9de2d78e2 100644 --- a/django-diary/source_code_step_2/entries/admin.py +++ b/django-diary/source_code_step_2/entries/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_3/diary/urls.py b/django-diary/source_code_step_3/diary/urls.py index 9d657419e8..019b0efada 100644 --- a/django-diary/source_code_step_3/diary/urls.py +++ b/django-diary/source_code_step_3/diary/urls.py @@ -15,7 +15,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_3/entries/admin.py b/django-diary/source_code_step_3/entries/admin.py index 9047611e37..f9de2d78e2 100644 --- a/django-diary/source_code_step_3/entries/admin.py +++ b/django-diary/source_code_step_3/entries/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_3/entries/tests.py b/django-diary/source_code_step_3/entries/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/django-diary/source_code_step_3/entries/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-diary/source_code_step_3/entries/views.py b/django-diary/source_code_step_3/entries/views.py index 6063445129..c6806a074b 100644 --- a/django-diary/source_code_step_3/entries/views.py +++ b/django-diary/source_code_step_3/entries/views.py @@ -1,7 +1,4 @@ -from django.views.generic import ( - ListView, - DetailView, -) +from django.views.generic import DetailView, ListView from .models import Entry diff --git a/django-diary/source_code_step_4/diary/urls.py b/django-diary/source_code_step_4/diary/urls.py index 9d657419e8..019b0efada 100644 --- a/django-diary/source_code_step_4/diary/urls.py +++ b/django-diary/source_code_step_4/diary/urls.py @@ -15,7 +15,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_4/entries/admin.py b/django-diary/source_code_step_4/entries/admin.py index 9047611e37..f9de2d78e2 100644 --- a/django-diary/source_code_step_4/entries/admin.py +++ b/django-diary/source_code_step_4/entries/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_4/entries/tests.py b/django-diary/source_code_step_4/entries/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/django-diary/source_code_step_4/entries/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-diary/source_code_step_4/entries/views.py b/django-diary/source_code_step_4/entries/views.py index 6063445129..c6806a074b 100644 --- a/django-diary/source_code_step_4/entries/views.py +++ b/django-diary/source_code_step_4/entries/views.py @@ -1,7 +1,4 @@ -from django.views.generic import ( - ListView, - DetailView, -) +from django.views.generic import DetailView, ListView from .models import Entry diff --git a/django-diary/source_code_step_5/diary/urls.py b/django-diary/source_code_step_5/diary/urls.py index 9d657419e8..019b0efada 100644 --- a/django-diary/source_code_step_5/diary/urls.py +++ b/django-diary/source_code_step_5/diary/urls.py @@ -15,7 +15,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_5/entries/admin.py b/django-diary/source_code_step_5/entries/admin.py index 9047611e37..f9de2d78e2 100644 --- a/django-diary/source_code_step_5/entries/admin.py +++ b/django-diary/source_code_step_5/entries/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_5/entries/tests.py b/django-diary/source_code_step_5/entries/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/django-diary/source_code_step_5/entries/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-diary/source_code_step_6/diary/urls.py b/django-diary/source_code_step_6/diary/urls.py index 9d657419e8..019b0efada 100644 --- a/django-diary/source_code_step_6/diary/urls.py +++ b/django-diary/source_code_step_6/diary/urls.py @@ -15,7 +15,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), diff --git a/django-diary/source_code_step_6/entries/admin.py b/django-diary/source_code_step_6/entries/admin.py index 9047611e37..f9de2d78e2 100644 --- a/django-diary/source_code_step_6/entries/admin.py +++ b/django-diary/source_code_step_6/entries/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Entry admin.site.register(Entry) diff --git a/django-diary/source_code_step_6/entries/tests.py b/django-diary/source_code_step_6/entries/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/django-diary/source_code_step_6/entries/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. From ebb909b73278465ff794a91b370d8a42307a437d Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:46:25 +0100 Subject: [PATCH 03/10] Move requirements into root folder --- django-diary/requirements.txt | 3 +++ django-diary/source_code_final/requirements.txt | 1 - django-diary/source_code_step_1/requirements.txt | 1 - django-diary/source_code_step_2/requirements.txt | 1 - django-diary/source_code_step_3/requirements.txt | 1 - django-diary/source_code_step_4/requirements.txt | 1 - django-diary/source_code_step_5/requirements.txt | 1 - django-diary/source_code_step_6/requirements.txt | 1 - 8 files changed, 3 insertions(+), 7 deletions(-) create mode 100644 django-diary/requirements.txt delete mode 100644 django-diary/source_code_final/requirements.txt delete mode 100644 django-diary/source_code_step_1/requirements.txt delete mode 100644 django-diary/source_code_step_2/requirements.txt delete mode 100644 django-diary/source_code_step_3/requirements.txt delete mode 100644 django-diary/source_code_step_4/requirements.txt delete mode 100644 django-diary/source_code_step_5/requirements.txt delete mode 100644 django-diary/source_code_step_6/requirements.txt diff --git a/django-diary/requirements.txt b/django-diary/requirements.txt new file mode 100644 index 0000000000..28e8c66750 --- /dev/null +++ b/django-diary/requirements.txt @@ -0,0 +1,3 @@ +asgiref==3.8.1 +Django==5.1.4 +sqlparse==0.5.3 diff --git a/django-diary/source_code_final/requirements.txt b/django-diary/source_code_final/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_final/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 diff --git a/django-diary/source_code_step_1/requirements.txt b/django-diary/source_code_step_1/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_step_1/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 diff --git a/django-diary/source_code_step_2/requirements.txt b/django-diary/source_code_step_2/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_step_2/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 diff --git a/django-diary/source_code_step_3/requirements.txt b/django-diary/source_code_step_3/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_step_3/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 diff --git a/django-diary/source_code_step_4/requirements.txt b/django-diary/source_code_step_4/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_step_4/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 diff --git a/django-diary/source_code_step_5/requirements.txt b/django-diary/source_code_step_5/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_step_5/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 diff --git a/django-diary/source_code_step_6/requirements.txt b/django-diary/source_code_step_6/requirements.txt deleted file mode 100644 index 23a3f716de..0000000000 --- a/django-diary/source_code_step_6/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Django==3.1.7 From 1901c6f67994ce978412f7e37813692c655c5440 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:46:38 +0100 Subject: [PATCH 04/10] Add new readme --- django-diary/README.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/django-diary/README.md b/django-diary/README.md index e0c0fc2080..ad3dd35464 100644 --- a/django-diary/README.md +++ b/django-diary/README.md @@ -1,13 +1,8 @@ -# Django Diary - -> **Note:** The project is built with `Python 3.9.1`, but should work with any Python3 version. - -## About this repository +# Build Your Personal Diary With Django This is a companion project to the ["Build Your Personal Diary With Django"](https://realpython.com/django-diary-project-python/) tutorial on Real Python. Visit the article to follow along or download the content of `source_code_final` folder from this repository. -## How To Run `django-diary` Type the following commands into a terminal to create and activate a virtual environment and install the requirements: @@ -16,8 +11,7 @@ $ python -m venv venv $ source venv/bin/activate $ python -m pip install -r requirements.txt ``` - -Then run the database migrations and create a superuser: +Then you can navigate into a step folder, run the database migrations, and create a superuser: ```sh $ python manage.py migrate @@ -30,6 +24,3 @@ Finally, run the local Django development server: $ python manage.py runserver ``` -## License - -Distributed under the MIT license. From 66ebca23c14da5f8d9ac476ab7c20dda767e9d86 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:47:04 +0100 Subject: [PATCH 05/10] Add formatted migrations --- .../entries/migrations/0001_initial.py | 32 +++++++++++++------ .../entries/migrations/0001_initial.py | 32 +++++++++++++------ .../entries/migrations/0001_initial.py | 32 +++++++++++++------ .../entries/migrations/0001_initial.py | 32 +++++++++++++------ .../entries/migrations/0001_initial.py | 32 +++++++++++++------ .../entries/migrations/0001_initial.py | 32 +++++++++++++------ 6 files changed, 132 insertions(+), 60 deletions(-) diff --git a/django-diary/source_code_final/entries/migrations/0001_initial.py b/django-diary/source_code_final/entries/migrations/0001_initial.py index 57ea37dfc2..f792651a73 100644 --- a/django-diary/source_code_final/entries/migrations/0001_initial.py +++ b/django-diary/source_code_final/entries/migrations/0001_initial.py @@ -1,24 +1,36 @@ -# Generated by Django 3.2.1 on 2021-05-09 17:12 +# Generated by Django 5.1.4 on 2025-01-06 17:01 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Entry', + name="Entry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=200)), - ('content', models.TextField()), - ('date_created', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("content", models.TextField()), + ( + "date_created", + models.DateTimeField(default=django.utils.timezone.now), + ), ], + options={ + "verbose_name_plural": "Entries", + }, ), ] diff --git a/django-diary/source_code_step_2/entries/migrations/0001_initial.py b/django-diary/source_code_step_2/entries/migrations/0001_initial.py index 57ea37dfc2..f792651a73 100644 --- a/django-diary/source_code_step_2/entries/migrations/0001_initial.py +++ b/django-diary/source_code_step_2/entries/migrations/0001_initial.py @@ -1,24 +1,36 @@ -# Generated by Django 3.2.1 on 2021-05-09 17:12 +# Generated by Django 5.1.4 on 2025-01-06 17:01 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Entry', + name="Entry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=200)), - ('content', models.TextField()), - ('date_created', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("content", models.TextField()), + ( + "date_created", + models.DateTimeField(default=django.utils.timezone.now), + ), ], + options={ + "verbose_name_plural": "Entries", + }, ), ] diff --git a/django-diary/source_code_step_3/entries/migrations/0001_initial.py b/django-diary/source_code_step_3/entries/migrations/0001_initial.py index 57ea37dfc2..f792651a73 100644 --- a/django-diary/source_code_step_3/entries/migrations/0001_initial.py +++ b/django-diary/source_code_step_3/entries/migrations/0001_initial.py @@ -1,24 +1,36 @@ -# Generated by Django 3.2.1 on 2021-05-09 17:12 +# Generated by Django 5.1.4 on 2025-01-06 17:01 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Entry', + name="Entry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=200)), - ('content', models.TextField()), - ('date_created', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("content", models.TextField()), + ( + "date_created", + models.DateTimeField(default=django.utils.timezone.now), + ), ], + options={ + "verbose_name_plural": "Entries", + }, ), ] diff --git a/django-diary/source_code_step_4/entries/migrations/0001_initial.py b/django-diary/source_code_step_4/entries/migrations/0001_initial.py index 57ea37dfc2..f792651a73 100644 --- a/django-diary/source_code_step_4/entries/migrations/0001_initial.py +++ b/django-diary/source_code_step_4/entries/migrations/0001_initial.py @@ -1,24 +1,36 @@ -# Generated by Django 3.2.1 on 2021-05-09 17:12 +# Generated by Django 5.1.4 on 2025-01-06 17:01 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Entry', + name="Entry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=200)), - ('content', models.TextField()), - ('date_created', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("content", models.TextField()), + ( + "date_created", + models.DateTimeField(default=django.utils.timezone.now), + ), ], + options={ + "verbose_name_plural": "Entries", + }, ), ] diff --git a/django-diary/source_code_step_5/entries/migrations/0001_initial.py b/django-diary/source_code_step_5/entries/migrations/0001_initial.py index 57ea37dfc2..f792651a73 100644 --- a/django-diary/source_code_step_5/entries/migrations/0001_initial.py +++ b/django-diary/source_code_step_5/entries/migrations/0001_initial.py @@ -1,24 +1,36 @@ -# Generated by Django 3.2.1 on 2021-05-09 17:12 +# Generated by Django 5.1.4 on 2025-01-06 17:01 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Entry', + name="Entry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=200)), - ('content', models.TextField()), - ('date_created', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("content", models.TextField()), + ( + "date_created", + models.DateTimeField(default=django.utils.timezone.now), + ), ], + options={ + "verbose_name_plural": "Entries", + }, ), ] diff --git a/django-diary/source_code_step_6/entries/migrations/0001_initial.py b/django-diary/source_code_step_6/entries/migrations/0001_initial.py index 57ea37dfc2..f792651a73 100644 --- a/django-diary/source_code_step_6/entries/migrations/0001_initial.py +++ b/django-diary/source_code_step_6/entries/migrations/0001_initial.py @@ -1,24 +1,36 @@ -# Generated by Django 3.2.1 on 2021-05-09 17:12 +# Generated by Django 5.1.4 on 2025-01-06 17:01 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Entry', + name="Entry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=200)), - ('content', models.TextField()), - ('date_created', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("content", models.TextField()), + ( + "date_created", + models.DateTimeField(default=django.utils.timezone.now), + ), ], + options={ + "verbose_name_plural": "Entries", + }, ), ] From 012c170a1237a68101b141f059d84f214533e5b3 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:47:51 +0100 Subject: [PATCH 06/10] Add CSS file --- django-diary/source_code_final/entries/static/css/diary.css | 1 - django-diary/source_code_step_4/entries/static/css/diary.css | 1 - django-diary/source_code_step_5/entries/static/css/diary.css | 1 - django-diary/source_code_step_6/entries/static/css/diary.css | 1 - 4 files changed, 4 deletions(-) diff --git a/django-diary/source_code_final/entries/static/css/diary.css b/django-diary/source_code_final/entries/static/css/diary.css index a6925aeb92..aa2090daa0 100644 --- a/django-diary/source_code_final/entries/static/css/diary.css +++ b/django-diary/source_code_final/entries/static/css/diary.css @@ -31,7 +31,6 @@ h2, h3 { } h2 { - /* background-color: lightpink; */ background-color: aquamarine; } diff --git a/django-diary/source_code_step_4/entries/static/css/diary.css b/django-diary/source_code_step_4/entries/static/css/diary.css index 25a05e43e3..825321a621 100644 --- a/django-diary/source_code_step_4/entries/static/css/diary.css +++ b/django-diary/source_code_step_4/entries/static/css/diary.css @@ -31,7 +31,6 @@ h2, h3 { } h2 { - /* background-color: lightpink; */ background-color: aquamarine; } diff --git a/django-diary/source_code_step_5/entries/static/css/diary.css b/django-diary/source_code_step_5/entries/static/css/diary.css index 25a05e43e3..825321a621 100644 --- a/django-diary/source_code_step_5/entries/static/css/diary.css +++ b/django-diary/source_code_step_5/entries/static/css/diary.css @@ -31,7 +31,6 @@ h2, h3 { } h2 { - /* background-color: lightpink; */ background-color: aquamarine; } diff --git a/django-diary/source_code_step_6/entries/static/css/diary.css b/django-diary/source_code_step_6/entries/static/css/diary.css index a6925aeb92..aa2090daa0 100644 --- a/django-diary/source_code_step_6/entries/static/css/diary.css +++ b/django-diary/source_code_step_6/entries/static/css/diary.css @@ -31,7 +31,6 @@ h2, h3 { } h2 { - /* background-color: lightpink; */ background-color: aquamarine; } From cc63dfedfba54061269066b1dd42ab894d51b2ad Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:48:08 +0100 Subject: [PATCH 07/10] Add templates --- .../entries/templates/entries/base.html | 50 +++++++++---------- .../entries/entry_confirm_delete.html | 8 +-- .../templates/entries/entry_detail.html | 12 ++--- .../entries/templates/entries/entry_form.html | 9 ++-- .../entries/templates/entries/entry_list.html | 31 ++++++------ .../templates/entries/entry_detail.html | 2 +- .../entries/templates/entries/entry_list.html | 10 ++-- .../entries/templates/entries/base.html | 28 +++++------ .../templates/entries/entry_detail.html | 3 +- .../entries/templates/entries/entry_list.html | 11 ++-- .../entries/templates/entries/base.html | 26 +++++----- .../entries/entry_confirm_delete.html | 8 +-- .../templates/entries/entry_detail.html | 3 +- .../entries/templates/entries/entry_form.html | 9 ++-- .../entries/templates/entries/entry_list.html | 11 ++-- .../entries/templates/entries/base.html | 41 +++++++-------- .../entries/entry_confirm_delete.html | 8 +-- .../templates/entries/entry_detail.html | 12 ++--- .../entries/templates/entries/entry_form.html | 9 ++-- .../entries/templates/entries/entry_list.html | 31 ++++++------ 20 files changed, 147 insertions(+), 175 deletions(-) diff --git a/django-diary/source_code_final/entries/templates/entries/base.html b/django-diary/source_code_final/entries/templates/entries/base.html index 7ae979a73f..11cded607a 100644 --- a/django-diary/source_code_final/entries/templates/entries/base.html +++ b/django-diary/source_code_final/entries/templates/entries/base.html @@ -1,30 +1,26 @@ {% load static %} - - - - My Diary - - - - -

Dear diary …

- - {% if messages %} -
    - {% for message in messages %} -
  • - {{ message }} -
  • - {% endfor %} -
- {% endif %} - - {% block content %}{% endblock %} - -
- Logout - - - \ No newline at end of file + + + My Diary + + + +

+ Dear diary … +

+ {% if messages %} +
    + {% for message in messages %}
  • {{ message }}
  • {% endfor %} +
+ {% endif %} + {% block content %} + {% endblock content %} +
+
+ {% csrf_token %} + +
+ + diff --git a/django-diary/source_code_final/entries/templates/entries/entry_confirm_delete.html b/django-diary/source_code_final/entries/templates/entries/entry_confirm_delete.html index adece2c949..92b36ec747 100644 --- a/django-diary/source_code_final/entries/templates/entries/entry_confirm_delete.html +++ b/django-diary/source_code_final/entries/templates/entries/entry_confirm_delete.html @@ -1,8 +1,10 @@ {% extends "entries/base.html" %} {% block content %} -
{% csrf_token %} + + {% csrf_token %}

- Are you sure you want to delete "{{ entry.title }}"
+ Are you sure you want to delete + "{{ entry.title }}" created on {{ entry.date_created|date:'Y-m-d' }}?

@@ -10,4 +12,4 @@ -{% endblock %} \ No newline at end of file +{% endblock content %} diff --git a/django-diary/source_code_final/entries/templates/entries/entry_detail.html b/django-diary/source_code_final/entries/templates/entries/entry_detail.html index 803af78ac4..0822dae4ba 100644 --- a/django-diary/source_code_final/entries/templates/entries/entry_detail.html +++ b/django-diary/source_code_final/entries/templates/entries/entry_detail.html @@ -1,14 +1,12 @@ {% extends "entries/base.html" %} - {% block content %}

{{ entry.date_created|date:'Y-m-d H:i' }}

{{ entry.title }}

{{ entry.content }}

- -

- ✍️ Edit - ⛔ Delete -

-{% endblock %} \ No newline at end of file +

+ ✍️ Edit + ⛔ Delete +

+{% endblock content %} diff --git a/django-diary/source_code_final/entries/templates/entries/entry_form.html b/django-diary/source_code_final/entries/templates/entries/entry_form.html index f3fc9e0517..a3d379692f 100644 --- a/django-diary/source_code_final/entries/templates/entries/entry_form.html +++ b/django-diary/source_code_final/entries/templates/entries/entry_form.html @@ -1,16 +1,17 @@ {% extends "entries/base.html" %} {% block content %} - {% csrf_token %} + + {% csrf_token %} {{ form.as_p }}
{% if entry %} - + {% else %} - + {% endif %} -{% endblock %} \ No newline at end of file +{% endblock content %} diff --git a/django-diary/source_code_final/entries/templates/entries/entry_list.html b/django-diary/source_code_final/entries/templates/entries/entry_list.html index 9c6e07e767..bf5949f15d 100644 --- a/django-diary/source_code_final/entries/templates/entries/entry_list.html +++ b/django-diary/source_code_final/entries/templates/entries/entry_list.html @@ -1,20 +1,19 @@ {% extends "entries/base.html" %} - {% block content %} +{% for entry in entry_list %} + - {% for entry in entry_list %} - - {% endfor %} -{% endblock %} +{% endfor %} +{% endblock content %} diff --git a/django-diary/source_code_step_3/entries/templates/entries/entry_detail.html b/django-diary/source_code_step_3/entries/templates/entries/entry_detail.html index 8290b891e9..546592c967 100644 --- a/django-diary/source_code_step_3/entries/templates/entries/entry_detail.html +++ b/django-diary/source_code_step_3/entries/templates/entries/entry_detail.html @@ -2,4 +2,4 @@

{{ entry.date_created|date:'Y-m-d H:i' }}

{{ entry.title }}

{{ entry.content }}

- \ No newline at end of file + diff --git a/django-diary/source_code_step_3/entries/templates/entries/entry_list.html b/django-diary/source_code_step_3/entries/templates/entries/entry_list.html index 3b18493683..7bee2797f5 100644 --- a/django-diary/source_code_step_3/entries/templates/entries/entry_list.html +++ b/django-diary/source_code_step_3/entries/templates/entries/entry_list.html @@ -1,12 +1,8 @@ {% for entry in entry_list %} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/django-diary/source_code_step_4/entries/templates/entries/base.html b/django-diary/source_code_step_4/entries/templates/entries/base.html index b3c5014592..e0a5b4befa 100644 --- a/django-diary/source_code_step_4/entries/templates/entries/base.html +++ b/django-diary/source_code_step_4/entries/templates/entries/base.html @@ -1,18 +1,16 @@ {% load static %} - - - - My Diary - - - - -

Dear diary …

- - {% block content %}{% endblock %} - - - - \ No newline at end of file + + + My Diary + + + +

+ Dear diary … +

+ {% block content %} + {% endblock content %} + + diff --git a/django-diary/source_code_step_4/entries/templates/entries/entry_detail.html b/django-diary/source_code_step_4/entries/templates/entries/entry_detail.html index e868da42ad..9dc5160199 100644 --- a/django-diary/source_code_step_4/entries/templates/entries/entry_detail.html +++ b/django-diary/source_code_step_4/entries/templates/entries/entry_detail.html @@ -1,9 +1,8 @@ {% extends "entries/base.html" %} - {% block content %}

{{ entry.date_created|date:'Y-m-d H:i' }}

{{ entry.title }}

{{ entry.content }}

-{% endblock %} \ No newline at end of file +{% endblock content %} diff --git a/django-diary/source_code_step_4/entries/templates/entries/entry_list.html b/django-diary/source_code_step_4/entries/templates/entries/entry_list.html index c50e961901..f12a2159df 100644 --- a/django-diary/source_code_step_4/entries/templates/entries/entry_list.html +++ b/django-diary/source_code_step_4/entries/templates/entries/entry_list.html @@ -1,16 +1,11 @@ {% extends "entries/base.html" %} - {% block content %} {% for entry in entry_list %} {% endfor %} -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_5/entries/templates/entries/base.html b/django-diary/source_code_step_5/entries/templates/entries/base.html index cc8bfd52d8..e0a5b4befa 100644 --- a/django-diary/source_code_step_5/entries/templates/entries/base.html +++ b/django-diary/source_code_step_5/entries/templates/entries/base.html @@ -1,18 +1,16 @@ {% load static %} - - - - My Diary - - - - -

Dear diary …

- - {% block content %}{% endblock %} - - - + + + My Diary + + + +

+ Dear diary … +

+ {% block content %} + {% endblock content %} + diff --git a/django-diary/source_code_step_5/entries/templates/entries/entry_confirm_delete.html b/django-diary/source_code_step_5/entries/templates/entries/entry_confirm_delete.html index c5a6a674d8..92b36ec747 100644 --- a/django-diary/source_code_step_5/entries/templates/entries/entry_confirm_delete.html +++ b/django-diary/source_code_step_5/entries/templates/entries/entry_confirm_delete.html @@ -1,8 +1,10 @@ {% extends "entries/base.html" %} {% block content %} -
{% csrf_token %} + + {% csrf_token %}

- Are you sure you want to delete "{{ entry.title }}"
+ Are you sure you want to delete + "{{ entry.title }}" created on {{ entry.date_created|date:'Y-m-d' }}?

@@ -10,4 +12,4 @@ -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_5/entries/templates/entries/entry_detail.html b/django-diary/source_code_step_5/entries/templates/entries/entry_detail.html index 2b994a1a8a..9dc5160199 100644 --- a/django-diary/source_code_step_5/entries/templates/entries/entry_detail.html +++ b/django-diary/source_code_step_5/entries/templates/entries/entry_detail.html @@ -1,9 +1,8 @@ {% extends "entries/base.html" %} - {% block content %}

{{ entry.date_created|date:'Y-m-d H:i' }}

{{ entry.title }}

{{ entry.content }}

-{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_5/entries/templates/entries/entry_form.html b/django-diary/source_code_step_5/entries/templates/entries/entry_form.html index 468762bc06..a3d379692f 100644 --- a/django-diary/source_code_step_5/entries/templates/entries/entry_form.html +++ b/django-diary/source_code_step_5/entries/templates/entries/entry_form.html @@ -1,16 +1,17 @@ {% extends "entries/base.html" %} {% block content %} - {% csrf_token %} + + {% csrf_token %} {{ form.as_p }}
{% if entry %} - + {% else %} - + {% endif %} -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_5/entries/templates/entries/entry_list.html b/django-diary/source_code_step_5/entries/templates/entries/entry_list.html index c50e961901..f12a2159df 100644 --- a/django-diary/source_code_step_5/entries/templates/entries/entry_list.html +++ b/django-diary/source_code_step_5/entries/templates/entries/entry_list.html @@ -1,16 +1,11 @@ {% extends "entries/base.html" %} - {% block content %} {% for entry in entry_list %} {% endfor %} -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_6/entries/templates/entries/base.html b/django-diary/source_code_step_6/entries/templates/entries/base.html index fc24724313..fae99f3412 100644 --- a/django-diary/source_code_step_6/entries/templates/entries/base.html +++ b/django-diary/source_code_step_6/entries/templates/entries/base.html @@ -1,28 +1,21 @@ {% load static %} - - - - My Diary - - - - -

Dear diary …

- - {% if messages %} -
    - {% for message in messages %} -
  • - {{ message }} -
  • - {% endfor %} -
- {% endif %} - - {% block content %}{% endblock %} - - - + + + My Diary + + + +

+ Dear diary … +

+ {% if messages %} +
    + {% for message in messages %}
  • {{ message }}
  • {% endfor %} +
+ {% endif %} + {% block content %} + {% endblock content %} + diff --git a/django-diary/source_code_step_6/entries/templates/entries/entry_confirm_delete.html b/django-diary/source_code_step_6/entries/templates/entries/entry_confirm_delete.html index c5a6a674d8..92b36ec747 100644 --- a/django-diary/source_code_step_6/entries/templates/entries/entry_confirm_delete.html +++ b/django-diary/source_code_step_6/entries/templates/entries/entry_confirm_delete.html @@ -1,8 +1,10 @@ {% extends "entries/base.html" %} {% block content %} -
{% csrf_token %} + + {% csrf_token %}

- Are you sure you want to delete "{{ entry.title }}"
+ Are you sure you want to delete + "{{ entry.title }}" created on {{ entry.date_created|date:'Y-m-d' }}?

@@ -10,4 +12,4 @@ -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_6/entries/templates/entries/entry_detail.html b/django-diary/source_code_step_6/entries/templates/entries/entry_detail.html index 1c74c58af3..0822dae4ba 100644 --- a/django-diary/source_code_step_6/entries/templates/entries/entry_detail.html +++ b/django-diary/source_code_step_6/entries/templates/entries/entry_detail.html @@ -1,14 +1,12 @@ {% extends "entries/base.html" %} - {% block content %}

{{ entry.date_created|date:'Y-m-d H:i' }}

{{ entry.title }}

{{ entry.content }}

- -

- ✍️ Edit - ⛔ Delete -

-{% endblock %} +

+ ✍️ Edit + ⛔ Delete +

+{% endblock content %} diff --git a/django-diary/source_code_step_6/entries/templates/entries/entry_form.html b/django-diary/source_code_step_6/entries/templates/entries/entry_form.html index 468762bc06..a3d379692f 100644 --- a/django-diary/source_code_step_6/entries/templates/entries/entry_form.html +++ b/django-diary/source_code_step_6/entries/templates/entries/entry_form.html @@ -1,16 +1,17 @@ {% extends "entries/base.html" %} {% block content %} - {% csrf_token %} + + {% csrf_token %} {{ form.as_p }}
{% if entry %} - + {% else %} - + {% endif %} -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_6/entries/templates/entries/entry_list.html b/django-diary/source_code_step_6/entries/templates/entries/entry_list.html index 9c6e07e767..bf5949f15d 100644 --- a/django-diary/source_code_step_6/entries/templates/entries/entry_list.html +++ b/django-diary/source_code_step_6/entries/templates/entries/entry_list.html @@ -1,20 +1,19 @@ {% extends "entries/base.html" %} - {% block content %} +{% for entry in entry_list %} + - {% for entry in entry_list %} - - {% endfor %} -{% endblock %} +{% endfor %} +{% endblock content %} From 23abf918b6597c11807b5f2a00b0e7a421438743 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:53:27 +0100 Subject: [PATCH 08/10] Removed test files --- django-diary/source_code_final/entries/tests.py | 3 --- django-diary/source_code_step_2/entries/tests.py | 3 --- django-diary/source_code_step_3/entries/tests.py | 3 --- django-diary/source_code_step_4/entries/tests.py | 3 --- django-diary/source_code_step_5/entries/tests.py | 3 --- django-diary/source_code_step_6/entries/tests.py | 3 --- 6 files changed, 18 deletions(-) delete mode 100644 django-diary/source_code_final/entries/tests.py delete mode 100644 django-diary/source_code_step_2/entries/tests.py delete mode 100644 django-diary/source_code_step_3/entries/tests.py delete mode 100644 django-diary/source_code_step_4/entries/tests.py delete mode 100644 django-diary/source_code_step_5/entries/tests.py delete mode 100644 django-diary/source_code_step_6/entries/tests.py diff --git a/django-diary/source_code_final/entries/tests.py b/django-diary/source_code_final/entries/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/django-diary/source_code_final/entries/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/django-diary/source_code_step_2/entries/tests.py b/django-diary/source_code_step_2/entries/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/django-diary/source_code_step_2/entries/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/django-diary/source_code_step_3/entries/tests.py b/django-diary/source_code_step_3/entries/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/django-diary/source_code_step_3/entries/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/django-diary/source_code_step_4/entries/tests.py b/django-diary/source_code_step_4/entries/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/django-diary/source_code_step_4/entries/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/django-diary/source_code_step_5/entries/tests.py b/django-diary/source_code_step_5/entries/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/django-diary/source_code_step_5/entries/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/django-diary/source_code_step_6/entries/tests.py b/django-diary/source_code_step_6/entries/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/django-diary/source_code_step_6/entries/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. From 2f5fe1ed028cf465fd0dcee7fdd00155b471e96b Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 13:56:05 +0100 Subject: [PATCH 09/10] Add placeholder content for empty file --- django-diary/source_code_step_2/entries/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/django-diary/source_code_step_2/entries/views.py b/django-diary/source_code_step_2/entries/views.py index 91ea44a218..48f5491bed 100644 --- a/django-diary/source_code_step_2/entries/views.py +++ b/django-diary/source_code_step_2/entries/views.py @@ -1,3 +1 @@ -from django.shortcuts import render - -# Create your views here. +# This file will be used in the next step From a672fd1eedc50c8aac8c63d4c8d5bbbd86f6f210 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 8 Jan 2025 14:08:44 +0100 Subject: [PATCH 10/10] Remove docstring from urls.py files --- django-diary/source_code_final/diary/urls.py | 16 ---------------- django-diary/source_code_step_1/diary/urls.py | 16 ---------------- django-diary/source_code_step_2/diary/urls.py | 16 ---------------- django-diary/source_code_step_3/diary/urls.py | 16 ---------------- django-diary/source_code_step_4/diary/urls.py | 16 ---------------- django-diary/source_code_step_5/diary/urls.py | 16 ---------------- django-diary/source_code_step_6/diary/urls.py | 16 ---------------- 7 files changed, 112 deletions(-) diff --git a/django-diary/source_code_final/diary/urls.py b/django-diary/source_code_final/diary/urls.py index 019b0efada..7e0dbbe031 100644 --- a/django-diary/source_code_final/diary/urls.py +++ b/django-diary/source_code_final/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import include, path diff --git a/django-diary/source_code_step_1/diary/urls.py b/django-diary/source_code_step_1/diary/urls.py index d71754adf2..083932c6e2 100644 --- a/django-diary/source_code_step_1/diary/urls.py +++ b/django-diary/source_code_step_1/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import path diff --git a/django-diary/source_code_step_2/diary/urls.py b/django-diary/source_code_step_2/diary/urls.py index d71754adf2..083932c6e2 100644 --- a/django-diary/source_code_step_2/diary/urls.py +++ b/django-diary/source_code_step_2/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import path diff --git a/django-diary/source_code_step_3/diary/urls.py b/django-diary/source_code_step_3/diary/urls.py index 019b0efada..7e0dbbe031 100644 --- a/django-diary/source_code_step_3/diary/urls.py +++ b/django-diary/source_code_step_3/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import include, path diff --git a/django-diary/source_code_step_4/diary/urls.py b/django-diary/source_code_step_4/diary/urls.py index 019b0efada..7e0dbbe031 100644 --- a/django-diary/source_code_step_4/diary/urls.py +++ b/django-diary/source_code_step_4/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import include, path diff --git a/django-diary/source_code_step_5/diary/urls.py b/django-diary/source_code_step_5/diary/urls.py index 019b0efada..7e0dbbe031 100644 --- a/django-diary/source_code_step_5/diary/urls.py +++ b/django-diary/source_code_step_5/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import include, path diff --git a/django-diary/source_code_step_6/diary/urls.py b/django-diary/source_code_step_6/diary/urls.py index 019b0efada..7e0dbbe031 100644 --- a/django-diary/source_code_step_6/diary/urls.py +++ b/django-diary/source_code_step_6/diary/urls.py @@ -1,19 +1,3 @@ -""" -URL configuration for diary project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 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: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import include, path