diff --git a/django-hosting-heroku/README.md b/django-hosting-heroku/README.md
index e7426f869a..16d8f872af 100644
--- a/django-hosting-heroku/README.md
+++ b/django-hosting-heroku/README.md
@@ -1,6 +1,8 @@
# Hosting a Django Project on Heroku
-This is a companion project to a Real Python tutorial about [hosting a Django project on Heroku](https://realpython.com/django-hosting-on-heroku/). It's a bare-bones Django project without any views.
+This is a companion project to a Real Python tutorial about [hosting a Django project on Heroku](https://realpython.com/django-hosting-on-heroku/). It's a bare-bones Django project without any views, configured for Heroku with Gunicorn, WhiteNoise, dj-database-url, and psycopg.
+
+You'll need Python 3.12 or later, Git, and the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli). The project pins Python 3.15 for Heroku in its `.python-version` file.
## Instructions
@@ -26,7 +28,8 @@ Deploy the code to Heroku:
```shell
$ heroku login
$ heroku create
-$ heroku config:set DEBUG=True SECRET_KEY=$(head -c 32 /dev/urandom | base64)
+$ heroku addons:create heroku-postgresql:essential-0
+$ heroku config:set SECRET_KEY=$(head -c 32 /dev/urandom | base64)
$ git push heroku master
$ heroku open
```
@@ -42,11 +45,4 @@ $ source venv/bin/activate
(portfolio) $ heroku local
```
-Navigate your web browser to
-
-**Note:** If you're on a Mac, then you may run into issues with the `heroku local` command above. To mitigate it, try commenting out the line with your `DATABASE_URL` variable from the `.env` file. Alternatively, you can uninstall the `psycopg2` driver and install its binary counterpart:
-
-```console
-$ pip uninstall psycopg2
-$ pip install psycopg2-binary
-```
+Navigate your web browser to
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/.gitignore b/django-hosting-heroku/source_code_final/portfolio-project/.gitignore
index b8f4aa5d3e..ce75bdadf0 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/.gitignore
+++ b/django-hosting-heroku/source_code_final/portfolio-project/.gitignore
@@ -1,4 +1,3 @@
-
# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm+all,django
@@ -107,7 +106,22 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+.pdm.toml
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
@@ -150,6 +164,13 @@ dmypy.json
# Cython debug symbols
cython_debug/
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
### PyCharm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@@ -214,6 +235,9 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
+# SonarLint plugin
+.idea/sonarlint/
+
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
@@ -227,20 +251,13 @@ fabric.properties
.idea/caches/build_file_checksums.ser
### PyCharm+all Patch ###
-# Ignores the whole .idea folder and all .iml files
-# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+# Ignore everything but code style settings and run configurations
+# that are supposed to be shared within teams.
-.idea/
+.idea/*
-# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
-
-*.iml
-modules.xml
-.idea/misc.xml
-*.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
+!.idea/codeStyles
+!.idea/runConfigurations
### Python ###
# Byte-compiled / optimized / DLL files
@@ -284,7 +301,19 @@ modules.xml
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
# Celery stuff
@@ -306,4 +335,21 @@ modules.xml
# Cython debug symbols
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+
+### Python Patch ###
+# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
+poetry.toml
+
+# ruff
+.ruff_cache/
+
+# LSP config files
+pyrightconfig.json
+
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
+staticfiles/
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/.python-version b/django-hosting-heroku/source_code_final/portfolio-project/.python-version
new file mode 100644
index 0000000000..93a848f968
--- /dev/null
+++ b/django-hosting-heroku/source_code_final/portfolio-project/.python-version
@@ -0,0 +1 @@
+3.15
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/Procfile b/django-hosting-heroku/source_code_final/portfolio-project/Procfile
index 5363888127..9d6b98e0c6 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/Procfile
+++ b/django-hosting-heroku/source_code_final/portfolio-project/Procfile
@@ -1,2 +1,2 @@
-web: python manage.py runserver 0.0.0.0:$PORT
+web: gunicorn portfolio.wsgi
release: python manage.py migrate
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/asgi.py b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/asgi.py
index 14a835aad5..8de01e804d 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/asgi.py
+++ b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/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/6.1/howto/deployment/asgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/settings.py b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/settings.py
index c8ac117b9c..1fd75cb056 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/settings.py
+++ b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/settings.py
@@ -1,33 +1,35 @@
"""
Django settings for portfolio project.
-Generated by 'django-admin startproject' using Django 3.2.5.
+Generated by 'django-admin startproject' using Django 6.1.4.
For more information on this file, see
-https://docs.djangoproject.com/en/3.2/topics/settings/
+https://docs.djangoproject.com/en/6.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/6.1/ref/settings/
"""
+import os
from pathlib import Path
-import django_heroku
+import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
-# SECRET_KEY = 'django-insecure-=bad%3%tbrw8(ohgu2uyi7)acv!$1br3=j-o)i@b+1d9g-sd1('
+SECRET_KEY = os.environ["SECRET_KEY"]
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0", ".herokuapp.com"]
+CSRF_TRUSTED_ORIGINS = ["https://*.herokuapp.com"]
# Application definition
@@ -43,6 +45,7 @@
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
+ "whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
@@ -60,7 +63,6 @@
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
- "django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
@@ -73,18 +75,18 @@
# Database
-# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
+# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
DATABASES = {
- "default": {
- "ENGINE": "django.db.backends.sqlite3",
- "NAME": BASE_DIR / "db.sqlite3",
- }
+ "default": dj_database_url.config(
+ default=f"sqlite:///{BASE_DIR / 'db.sqlite3'}",
+ conn_max_age=600,
+ )
}
# Password validation
-# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -103,7 +105,7 @@
# Internationalization
-# https://docs.djangoproject.com/en/3.2/topics/i18n/
+# https://docs.djangoproject.com/en/6.1/topics/i18n/
LANGUAGE_CODE = "en-us"
@@ -111,19 +113,27 @@
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/6.1/howto/static-files/
-STATIC_URL = "/static/"
+STATIC_URL = "static/"
+STATIC_ROOT = BASE_DIR / "staticfiles"
+
+STORAGES = {
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+}
-# Default primary key field type
-# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
-DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+# Email
+# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
-django_heroku.settings(locals())
+MAILERS = {
+ "default": {
+ "BACKEND": "django.core.mail.backends.console.EmailBackend",
+ },
+}
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/urls.py b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/urls.py
index be059233be..d95d0baf8b 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/urls.py
+++ b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/urls.py
@@ -1,7 +1,8 @@
-"""portfolio URL Configuration
+"""
+URL configuration for portfolio 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/6.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/wsgi.py b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/wsgi.py
index d058c41b23..0abca996f0 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/portfolio/wsgi.py
+++ b/django-hosting-heroku/source_code_final/portfolio-project/portfolio/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/6.1/howto/deployment/wsgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/requirements.txt b/django-hosting-heroku/source_code_final/portfolio-project/requirements.txt
index f1a0d91ed6..c4cd7c7369 100644
--- a/django-hosting-heroku/source_code_final/portfolio-project/requirements.txt
+++ b/django-hosting-heroku/source_code_final/portfolio-project/requirements.txt
@@ -1,8 +1,8 @@
-asgiref==3.4.1
-dj-database-url==0.5.0
-Django==3.2.5
-django-heroku==0.3.1
-psycopg2==2.9.1
-pytz==2021.1
-sqlparse==0.4.1
-whitenoise==5.2.0
+asgiref==3.13.0
+dj-database-url==3.1.2
+Django==6.1.4
+gunicorn==27.0.1
+psycopg==3.3.9
+psycopg-binary==3.3.9
+sqlparse==0.6.1
+whitenoise==6.12.0
diff --git a/django-hosting-heroku/source_code_final/portfolio-project/runtime.txt b/django-hosting-heroku/source_code_final/portfolio-project/runtime.txt
deleted file mode 100644
index 9bff0e00f7..0000000000
--- a/django-hosting-heroku/source_code_final/portfolio-project/runtime.txt
+++ /dev/null
@@ -1 +0,0 @@
-python-3.9.6
diff --git a/django-hosting-heroku/source_code_step_1/portfolio-project/db.sqlite3 b/django-hosting-heroku/source_code_step_1/portfolio-project/db.sqlite3
index d4f7a7272d..7ab7c7fc79 100644
Binary files a/django-hosting-heroku/source_code_step_1/portfolio-project/db.sqlite3 and b/django-hosting-heroku/source_code_step_1/portfolio-project/db.sqlite3 differ
diff --git a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/asgi.py b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/asgi.py
index 14a835aad5..8de01e804d 100644
--- a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/asgi.py
+++ b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/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/6.1/howto/deployment/asgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/settings.py b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/settings.py
index fda9d31726..40283aad84 100644
--- a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/settings.py
+++ b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/settings.py
@@ -1,13 +1,13 @@
"""
Django settings for portfolio project.
-Generated by 'django-admin startproject' using Django 3.2.5.
+Generated by 'django-admin startproject' using Django 6.1.4.
For more information on this file, see
-https://docs.djangoproject.com/en/3.2/topics/settings/
+https://docs.djangoproject.com/en/6.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/6.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/6.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = (
- "django-insecure-=bad%3%tbrw8(ohgu2uyi7)acv!$1br3=j-o)i@b+1d9g-sd1("
+ "django-insecure-1l$nfbh582og0bu+-*6l2&p$*ery90se-u1$$3whu#p4zi3cn4"
)
# SECURITY WARNING: don't run with debug turned on in production!
@@ -60,7 +60,6 @@
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
- "django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
@@ -73,7 +72,7 @@
# Database
-# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
+# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
DATABASES = {
"default": {
@@ -84,7 +83,7 @@
# Password validation
-# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -103,7 +102,7 @@
# Internationalization
-# https://docs.djangoproject.com/en/3.2/topics/i18n/
+# https://docs.djangoproject.com/en/6.1/topics/i18n/
LANGUAGE_CODE = "en-us"
@@ -111,17 +110,20 @@
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/6.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
+# Email
+# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
-DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+MAILERS = {
+ "default": {
+ "BACKEND": "django.core.mail.backends.console.EmailBackend",
+ },
+}
diff --git a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/urls.py b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/urls.py
index be059233be..d95d0baf8b 100644
--- a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/urls.py
+++ b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/urls.py
@@ -1,7 +1,8 @@
-"""portfolio URL Configuration
+"""
+URL configuration for portfolio 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/6.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
diff --git a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/wsgi.py b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/wsgi.py
index d058c41b23..0abca996f0 100644
--- a/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/wsgi.py
+++ b/django-hosting-heroku/source_code_step_1/portfolio-project/portfolio/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/6.1/howto/deployment/wsgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_1/portfolio-project/requirements.txt b/django-hosting-heroku/source_code_step_1/portfolio-project/requirements.txt
index 2ff0244539..29848f2e42 100644
--- a/django-hosting-heroku/source_code_step_1/portfolio-project/requirements.txt
+++ b/django-hosting-heroku/source_code_step_1/portfolio-project/requirements.txt
@@ -1,4 +1,3 @@
-asgiref==3.4.1
-Django==3.2.5
-pytz==2021.1
-sqlparse==0.4.1
+asgiref==3.13.0
+Django==6.1.4
+sqlparse==0.6.1
diff --git a/django-hosting-heroku/source_code_step_2/portfolio-project/.gitignore b/django-hosting-heroku/source_code_step_2/portfolio-project/.gitignore
index b8f4aa5d3e..c9d88efda4 100644
--- a/django-hosting-heroku/source_code_step_2/portfolio-project/.gitignore
+++ b/django-hosting-heroku/source_code_step_2/portfolio-project/.gitignore
@@ -1,4 +1,3 @@
-
# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm+all,django
@@ -107,7 +106,22 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+.pdm.toml
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
@@ -150,6 +164,13 @@ dmypy.json
# Cython debug symbols
cython_debug/
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
### PyCharm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@@ -214,6 +235,9 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
+# SonarLint plugin
+.idea/sonarlint/
+
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
@@ -227,20 +251,13 @@ fabric.properties
.idea/caches/build_file_checksums.ser
### PyCharm+all Patch ###
-# Ignores the whole .idea folder and all .iml files
-# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+# Ignore everything but code style settings and run configurations
+# that are supposed to be shared within teams.
-.idea/
+.idea/*
-# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
-
-*.iml
-modules.xml
-.idea/misc.xml
-*.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
+!.idea/codeStyles
+!.idea/runConfigurations
### Python ###
# Byte-compiled / optimized / DLL files
@@ -284,7 +301,19 @@ modules.xml
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
# Celery stuff
@@ -306,4 +335,20 @@ modules.xml
# Cython debug symbols
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+
+### Python Patch ###
+# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
+poetry.toml
+
+# ruff
+.ruff_cache/
+
+# LSP config files
+pyrightconfig.json
+
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
diff --git a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/asgi.py b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/asgi.py
index 14a835aad5..8de01e804d 100644
--- a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/asgi.py
+++ b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/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/6.1/howto/deployment/asgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/settings.py b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/settings.py
index fda9d31726..40283aad84 100644
--- a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/settings.py
+++ b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/settings.py
@@ -1,13 +1,13 @@
"""
Django settings for portfolio project.
-Generated by 'django-admin startproject' using Django 3.2.5.
+Generated by 'django-admin startproject' using Django 6.1.4.
For more information on this file, see
-https://docs.djangoproject.com/en/3.2/topics/settings/
+https://docs.djangoproject.com/en/6.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/6.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/6.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = (
- "django-insecure-=bad%3%tbrw8(ohgu2uyi7)acv!$1br3=j-o)i@b+1d9g-sd1("
+ "django-insecure-1l$nfbh582og0bu+-*6l2&p$*ery90se-u1$$3whu#p4zi3cn4"
)
# SECURITY WARNING: don't run with debug turned on in production!
@@ -60,7 +60,6 @@
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
- "django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
@@ -73,7 +72,7 @@
# Database
-# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
+# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
DATABASES = {
"default": {
@@ -84,7 +83,7 @@
# Password validation
-# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -103,7 +102,7 @@
# Internationalization
-# https://docs.djangoproject.com/en/3.2/topics/i18n/
+# https://docs.djangoproject.com/en/6.1/topics/i18n/
LANGUAGE_CODE = "en-us"
@@ -111,17 +110,20 @@
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/6.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
+# Email
+# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
-DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+MAILERS = {
+ "default": {
+ "BACKEND": "django.core.mail.backends.console.EmailBackend",
+ },
+}
diff --git a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/urls.py b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/urls.py
index be059233be..d95d0baf8b 100644
--- a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/urls.py
+++ b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/urls.py
@@ -1,7 +1,8 @@
-"""portfolio URL Configuration
+"""
+URL configuration for portfolio 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/6.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
diff --git a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/wsgi.py b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/wsgi.py
index d058c41b23..0abca996f0 100644
--- a/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/wsgi.py
+++ b/django-hosting-heroku/source_code_step_2/portfolio-project/portfolio/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/6.1/howto/deployment/wsgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_2/portfolio-project/requirements.txt b/django-hosting-heroku/source_code_step_2/portfolio-project/requirements.txt
index 2ff0244539..29848f2e42 100644
--- a/django-hosting-heroku/source_code_step_2/portfolio-project/requirements.txt
+++ b/django-hosting-heroku/source_code_step_2/portfolio-project/requirements.txt
@@ -1,4 +1,3 @@
-asgiref==3.4.1
-Django==3.2.5
-pytz==2021.1
-sqlparse==0.4.1
+asgiref==3.13.0
+Django==6.1.4
+sqlparse==0.6.1
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/.gitignore b/django-hosting-heroku/source_code_step_7/portfolio-project/.gitignore
index b8f4aa5d3e..ce75bdadf0 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/.gitignore
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/.gitignore
@@ -1,4 +1,3 @@
-
# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm+all,django
@@ -107,7 +106,22 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+.pdm.toml
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
@@ -150,6 +164,13 @@ dmypy.json
# Cython debug symbols
cython_debug/
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
### PyCharm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@@ -214,6 +235,9 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
+# SonarLint plugin
+.idea/sonarlint/
+
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
@@ -227,20 +251,13 @@ fabric.properties
.idea/caches/build_file_checksums.ser
### PyCharm+all Patch ###
-# Ignores the whole .idea folder and all .iml files
-# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+# Ignore everything but code style settings and run configurations
+# that are supposed to be shared within teams.
-.idea/
+.idea/*
-# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
-
-*.iml
-modules.xml
-.idea/misc.xml
-*.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
+!.idea/codeStyles
+!.idea/runConfigurations
### Python ###
# Byte-compiled / optimized / DLL files
@@ -284,7 +301,19 @@ modules.xml
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
# Celery stuff
@@ -306,4 +335,21 @@ modules.xml
# Cython debug symbols
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+
+### Python Patch ###
+# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
+poetry.toml
+
+# ruff
+.ruff_cache/
+
+# LSP config files
+pyrightconfig.json
+
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
+staticfiles/
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/.python-version b/django-hosting-heroku/source_code_step_7/portfolio-project/.python-version
new file mode 100644
index 0000000000..93a848f968
--- /dev/null
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/.python-version
@@ -0,0 +1 @@
+3.15
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/Procfile b/django-hosting-heroku/source_code_step_7/portfolio-project/Procfile
index 18ad15a45e..df9382026e 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/Procfile
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/Procfile
@@ -1 +1 @@
-web: python manage.py runserver 0.0.0.0:$PORT
+web: gunicorn portfolio.wsgi
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/asgi.py b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/asgi.py
index 14a835aad5..8de01e804d 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/asgi.py
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/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/6.1/howto/deployment/asgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/settings.py b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/settings.py
index c8ac117b9c..1fd75cb056 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/settings.py
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/settings.py
@@ -1,33 +1,35 @@
"""
Django settings for portfolio project.
-Generated by 'django-admin startproject' using Django 3.2.5.
+Generated by 'django-admin startproject' using Django 6.1.4.
For more information on this file, see
-https://docs.djangoproject.com/en/3.2/topics/settings/
+https://docs.djangoproject.com/en/6.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/6.1/ref/settings/
"""
+import os
from pathlib import Path
-import django_heroku
+import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
-# SECRET_KEY = 'django-insecure-=bad%3%tbrw8(ohgu2uyi7)acv!$1br3=j-o)i@b+1d9g-sd1('
+SECRET_KEY = os.environ["SECRET_KEY"]
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0", ".herokuapp.com"]
+CSRF_TRUSTED_ORIGINS = ["https://*.herokuapp.com"]
# Application definition
@@ -43,6 +45,7 @@
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
+ "whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
@@ -60,7 +63,6 @@
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
- "django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
@@ -73,18 +75,18 @@
# Database
-# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
+# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
DATABASES = {
- "default": {
- "ENGINE": "django.db.backends.sqlite3",
- "NAME": BASE_DIR / "db.sqlite3",
- }
+ "default": dj_database_url.config(
+ default=f"sqlite:///{BASE_DIR / 'db.sqlite3'}",
+ conn_max_age=600,
+ )
}
# Password validation
-# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -103,7 +105,7 @@
# Internationalization
-# https://docs.djangoproject.com/en/3.2/topics/i18n/
+# https://docs.djangoproject.com/en/6.1/topics/i18n/
LANGUAGE_CODE = "en-us"
@@ -111,19 +113,27 @@
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/6.1/howto/static-files/
-STATIC_URL = "/static/"
+STATIC_URL = "static/"
+STATIC_ROOT = BASE_DIR / "staticfiles"
+
+STORAGES = {
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+}
-# Default primary key field type
-# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
-DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+# Email
+# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
-django_heroku.settings(locals())
+MAILERS = {
+ "default": {
+ "BACKEND": "django.core.mail.backends.console.EmailBackend",
+ },
+}
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/urls.py b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/urls.py
index be059233be..d95d0baf8b 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/urls.py
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/urls.py
@@ -1,7 +1,8 @@
-"""portfolio URL Configuration
+"""
+URL configuration for portfolio 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/6.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/wsgi.py b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/wsgi.py
index d058c41b23..0abca996f0 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/wsgi.py
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/portfolio/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/6.1/howto/deployment/wsgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/requirements.txt b/django-hosting-heroku/source_code_step_7/portfolio-project/requirements.txt
index f1a0d91ed6..c4cd7c7369 100644
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/requirements.txt
+++ b/django-hosting-heroku/source_code_step_7/portfolio-project/requirements.txt
@@ -1,8 +1,8 @@
-asgiref==3.4.1
-dj-database-url==0.5.0
-Django==3.2.5
-django-heroku==0.3.1
-psycopg2==2.9.1
-pytz==2021.1
-sqlparse==0.4.1
-whitenoise==5.2.0
+asgiref==3.13.0
+dj-database-url==3.1.2
+Django==6.1.4
+gunicorn==27.0.1
+psycopg==3.3.9
+psycopg-binary==3.3.9
+sqlparse==0.6.1
+whitenoise==6.12.0
diff --git a/django-hosting-heroku/source_code_step_7/portfolio-project/runtime.txt b/django-hosting-heroku/source_code_step_7/portfolio-project/runtime.txt
deleted file mode 100644
index 9bff0e00f7..0000000000
--- a/django-hosting-heroku/source_code_step_7/portfolio-project/runtime.txt
+++ /dev/null
@@ -1 +0,0 @@
-python-3.9.6
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/.gitignore b/django-hosting-heroku/source_code_step_8/portfolio-project/.gitignore
index b8f4aa5d3e..ce75bdadf0 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/.gitignore
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/.gitignore
@@ -1,4 +1,3 @@
-
# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm+all,django
@@ -107,7 +106,22 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+.pdm.toml
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
@@ -150,6 +164,13 @@ dmypy.json
# Cython debug symbols
cython_debug/
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
### PyCharm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@@ -214,6 +235,9 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
+# SonarLint plugin
+.idea/sonarlint/
+
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
@@ -227,20 +251,13 @@ fabric.properties
.idea/caches/build_file_checksums.ser
### PyCharm+all Patch ###
-# Ignores the whole .idea folder and all .iml files
-# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+# Ignore everything but code style settings and run configurations
+# that are supposed to be shared within teams.
-.idea/
+.idea/*
-# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
-
-*.iml
-modules.xml
-.idea/misc.xml
-*.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
+!.idea/codeStyles
+!.idea/runConfigurations
### Python ###
# Byte-compiled / optimized / DLL files
@@ -284,7 +301,19 @@ modules.xml
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
# Celery stuff
@@ -306,4 +335,21 @@ modules.xml
# Cython debug symbols
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+
+### Python Patch ###
+# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
+poetry.toml
+
+# ruff
+.ruff_cache/
+
+# LSP config files
+pyrightconfig.json
+
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django
+staticfiles/
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/.python-version b/django-hosting-heroku/source_code_step_8/portfolio-project/.python-version
new file mode 100644
index 0000000000..93a848f968
--- /dev/null
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/.python-version
@@ -0,0 +1 @@
+3.15
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/Procfile b/django-hosting-heroku/source_code_step_8/portfolio-project/Procfile
index 5363888127..9d6b98e0c6 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/Procfile
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/Procfile
@@ -1,2 +1,2 @@
-web: python manage.py runserver 0.0.0.0:$PORT
+web: gunicorn portfolio.wsgi
release: python manage.py migrate
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/asgi.py b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/asgi.py
index 14a835aad5..8de01e804d 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/asgi.py
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/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/6.1/howto/deployment/asgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/settings.py b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/settings.py
index c8ac117b9c..1fd75cb056 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/settings.py
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/settings.py
@@ -1,33 +1,35 @@
"""
Django settings for portfolio project.
-Generated by 'django-admin startproject' using Django 3.2.5.
+Generated by 'django-admin startproject' using Django 6.1.4.
For more information on this file, see
-https://docs.djangoproject.com/en/3.2/topics/settings/
+https://docs.djangoproject.com/en/6.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/6.1/ref/settings/
"""
+import os
from pathlib import Path
-import django_heroku
+import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
-# SECRET_KEY = 'django-insecure-=bad%3%tbrw8(ohgu2uyi7)acv!$1br3=j-o)i@b+1d9g-sd1('
+SECRET_KEY = os.environ["SECRET_KEY"]
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0", ".herokuapp.com"]
+CSRF_TRUSTED_ORIGINS = ["https://*.herokuapp.com"]
# Application definition
@@ -43,6 +45,7 @@
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
+ "whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
@@ -60,7 +63,6 @@
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
- "django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
@@ -73,18 +75,18 @@
# Database
-# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
+# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
DATABASES = {
- "default": {
- "ENGINE": "django.db.backends.sqlite3",
- "NAME": BASE_DIR / "db.sqlite3",
- }
+ "default": dj_database_url.config(
+ default=f"sqlite:///{BASE_DIR / 'db.sqlite3'}",
+ conn_max_age=600,
+ )
}
# Password validation
-# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -103,7 +105,7 @@
# Internationalization
-# https://docs.djangoproject.com/en/3.2/topics/i18n/
+# https://docs.djangoproject.com/en/6.1/topics/i18n/
LANGUAGE_CODE = "en-us"
@@ -111,19 +113,27 @@
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/6.1/howto/static-files/
-STATIC_URL = "/static/"
+STATIC_URL = "static/"
+STATIC_ROOT = BASE_DIR / "staticfiles"
+
+STORAGES = {
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+}
-# Default primary key field type
-# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
-DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+# Email
+# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
-django_heroku.settings(locals())
+MAILERS = {
+ "default": {
+ "BACKEND": "django.core.mail.backends.console.EmailBackend",
+ },
+}
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/urls.py b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/urls.py
index be059233be..d95d0baf8b 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/urls.py
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/urls.py
@@ -1,7 +1,8 @@
-"""portfolio URL Configuration
+"""
+URL configuration for portfolio 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/6.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/wsgi.py b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/wsgi.py
index d058c41b23..0abca996f0 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/wsgi.py
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/portfolio/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/6.1/howto/deployment/wsgi/
"""
import os
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/requirements.txt b/django-hosting-heroku/source_code_step_8/portfolio-project/requirements.txt
index f1a0d91ed6..c4cd7c7369 100644
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/requirements.txt
+++ b/django-hosting-heroku/source_code_step_8/portfolio-project/requirements.txt
@@ -1,8 +1,8 @@
-asgiref==3.4.1
-dj-database-url==0.5.0
-Django==3.2.5
-django-heroku==0.3.1
-psycopg2==2.9.1
-pytz==2021.1
-sqlparse==0.4.1
-whitenoise==5.2.0
+asgiref==3.13.0
+dj-database-url==3.1.2
+Django==6.1.4
+gunicorn==27.0.1
+psycopg==3.3.9
+psycopg-binary==3.3.9
+sqlparse==0.6.1
+whitenoise==6.12.0
diff --git a/django-hosting-heroku/source_code_step_8/portfolio-project/runtime.txt b/django-hosting-heroku/source_code_step_8/portfolio-project/runtime.txt
deleted file mode 100644
index 9bff0e00f7..0000000000
--- a/django-hosting-heroku/source_code_step_8/portfolio-project/runtime.txt
+++ /dev/null
@@ -1 +0,0 @@
-python-3.9.6