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. 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/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/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/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_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_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 %} - - {% endif %} - - {% block content %}{% endblock %} - -
- Logout - - - \ No newline at end of file + + + My Diary + + + +

+ Dear diary … +

+ {% if messages %} + + {% 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 %}
-

{% now "Y-m-d H:i" %}

- +

+ {% now "Y-m-d H:i" %} +

+ + + +
+{% for entry in entry_list %} +
+

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

+

+ {{ entry.title }} +

- {% for entry in entry_list %} -
-

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

-

- - {{ entry.title }} - -

-
- {% endfor %} -{% endblock %} +{% endfor %} +{% endblock content %} 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/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..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 @@ -"""diary URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/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_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_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/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..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 @@ -"""diary URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/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/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/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_2/entries/views.py b/django-diary/source_code_step_2/entries/views.py index 68f1f58d06..48f5491bed 100644 --- a/django-diary/source_code_step_2/entries/views.py +++ b/django-diary/source_code_step_2/entries/views.py @@ -1 +1 @@ -# Content will be added in the next step +# This file will be used in the next step 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/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/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/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_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 %}
-

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

+

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

- - {{ entry.title }} - + {{ entry.title }}

-{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/django-diary/source_code_step_3/entries/views.py b/django-diary/source_code_step_3/entries/views.py index 8093802fc8..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 ( - DetailView, - ListView, -) +from django.views.generic import DetailView, ListView from .models import Entry 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/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/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/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_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_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 %}
-

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

+

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

- - {{ entry.title }} - + {{ entry.title }}

{% endfor %} -{% endblock %} +{% endblock content %} diff --git a/django-diary/source_code_step_4/entries/views.py b/django-diary/source_code_step_4/entries/views.py index 8093802fc8..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 ( - DetailView, - ListView, -) +from django.views.generic import DetailView, ListView from .models import Entry 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/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/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/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_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_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 %}
-

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

+

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

- - {{ entry.title }} - + {{ entry.title }}

{% endfor %} -{% endblock %} +{% endblock content %} 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/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/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/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", + }, ), ] 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; } 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 %} - - {% endif %} - - {% block content %}{% endblock %} - - - + + + My Diary + + + +

+ Dear diary … +

+ {% if messages %} + + {% 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 %}
-

{% now "Y-m-d H:i" %}

- +

+ {% now "Y-m-d H:i" %} +

+ + + +
+{% for entry in entry_list %} +
+

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

+

+ {{ entry.title }} +

- {% for entry in entry_list %} -
-

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

-

- - {{ entry.title }} - -

-
- {% endfor %} -{% endblock %} +{% endfor %} +{% endblock content %} 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