Skip to content

Commit 7f60d1d

Browse files
committed
Update
1 parent 601ca7a commit 7f60d1d

File tree

39 files changed

+304
-358
lines changed

39 files changed

+304
-358
lines changed

django-hosting-heroku/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to Host Your Django Project on Heroku
22

3-
This is a companion project to a tutorial on Real Python. It's a bare-bones Django project without any views.
3+
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.
44

55
## Instructions
66

@@ -26,19 +26,19 @@ Deploy the code to Heroku:
2626
```shell
2727
$ heroku login
2828
$ heroku create
29-
$ heroku config:set DEBUG=True SECRET_KEY=$(date | base64)
29+
$ heroku config:set DEBUG=True SECRET_KEY=$(head -c 32 /dev/urandom | base64)
3030
$ git push heroku master
3131
$ heroku open
3232
```
3333

3434
Optionally, for local development:
3535

3636
```shell
37-
$ python3 -m venv .venv
37+
$ python3 -m venv ./venv --prompt portfolio
3838
$ source .venv/bin/activate
39-
$ python3 -m pip install -r requirements.txt
40-
$ heroku config -s > .env
41-
$ heroku local
39+
(portfolio) $ python -m pip install -r requirements.txt
40+
(portfolio) $ heroku config -s > .env
41+
(portfolio) $ heroku local
4242
```
4343

4444
Navigate your web browser to <http://0.0.0.0:5000/>

django-hosting-heroku/source_code_final/portfolio-project/.gitignore

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ dist/
3232
downloads/
3333
eggs/
3434
.eggs/
35+
lib/
36+
lib64/
3537
parts/
3638
sdist/
3739
var/
3840
wheels/
39-
pip-wheel-metadata/
4041
share/python-wheels/
4142
*.egg-info/
4243
.installed.cfg
@@ -66,7 +67,7 @@ coverage.xml
6667
*.py,cover
6768
.hypothesis/
6869
.pytest_cache/
69-
pytestdebug.log
70+
cover/
7071

7172
# Translations
7273
*.mo
@@ -82,9 +83,9 @@ instance/
8283

8384
# Sphinx documentation
8485
docs/_build/
85-
doc/_build/
8686

8787
# PyBuilder
88+
.pybuilder/
8889
target/
8990

9091
# Jupyter Notebook
@@ -95,7 +96,9 @@ profile_default/
9596
ipython_config.py
9697

9798
# pyenv
98-
.python-version
99+
# For a library or package, you might want to ignore these files since the code is
100+
# intended to run in multiple environments; otherwise, check them in:
101+
# .python-version
99102

100103
# pipenv
101104
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
@@ -104,9 +107,6 @@ ipython_config.py
104107
# install all needed dependencies.
105108
#Pipfile.lock
106109

107-
# poetry
108-
#poetry.lock
109-
110110
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
111111
__pypackages__/
112112

@@ -118,15 +118,13 @@ celerybeat.pid
118118
*.sage.py
119119

120120
# Environments
121-
# .env
122-
.env/
123-
.venv/
121+
.env
122+
.venv
124123
env/
125124
venv/
126125
ENV/
127126
env.bak/
128127
venv.bak/
129-
pythonenv*
130128

131129
# Spyder project settings
132130
.spyderproject
@@ -149,15 +147,8 @@ dmypy.json
149147
# pytype static type analyzer
150148
.pytype/
151149

152-
# operating system-related files
153-
# file properties cache/storage on macOS
154-
*.DS_Store
155-
# thumbnail cache on Windows
156-
Thumbs.db
157-
158-
# profiling data
159-
.prof
160-
150+
# Cython debug symbols
151+
cython_debug/
161152

162153
### PyCharm+all ###
163154
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
@@ -170,6 +161,9 @@ Thumbs.db
170161
.idea/**/dictionaries
171162
.idea/**/shelf
172163

164+
# AWS User-specific
165+
.idea/**/aws.xml
166+
173167
# Generated files
174168
.idea/**/contentModel.xml
175169

@@ -280,23 +274,23 @@ modules.xml
280274
# IPython
281275

282276
# pyenv
277+
# For a library or package, you might want to ignore these files since the code is
278+
# intended to run in multiple environments; otherwise, check them in:
279+
# .python-version
283280

284281
# pipenv
285282
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
286283
# However, in case of collaboration, if having platform-specific dependencies or dependencies
287284
# having no cross-platform support, pipenv may install dependencies that don't work, or not
288285
# install all needed dependencies.
289286

290-
# poetry
291-
292287
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
293288

294289
# Celery stuff
295290

296291
# SageMath parsed files
297292

298293
# Environments
299-
# .env
300294

301295
# Spyder project settings
302296

@@ -310,11 +304,6 @@ modules.xml
310304

311305
# pytype static type analyzer
312306

313-
# operating system-related files
314-
# file properties cache/storage on macOS
315-
# thumbnail cache on Windows
316-
317-
# profiling data
318-
307+
# Cython debug symbols
319308

320309
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm+all,django

django-hosting-heroku/source_code_final/portfolio-project/manage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def main():
88
"""Run administrative tasks."""
9-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "portfolio.settings")
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'portfolio.settings')
1010
try:
1111
from django.core.management import execute_from_command_line
1212
except ImportError as exc:
@@ -18,5 +18,5 @@ def main():
1818
execute_from_command_line(sys.argv)
1919

2020

21-
if __name__ == "__main__":
21+
if __name__ == '__main__':
2222
main()

django-hosting-heroku/source_code_final/portfolio-project/portfolio/asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.asgi import get_asgi_application
1313

14-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "portfolio.settings")
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'portfolio.settings')
1515

1616
application = get_asgi_application()
Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Django settings for portfolio project.
33
4-
Generated by 'django-admin startproject' using Django 3.2.3.
4+
Generated by 'django-admin startproject' using Django 3.2.5.
55
66
For more information on this file, see
77
https://docs.djangoproject.com/en/3.2/topics/settings/
@@ -20,7 +20,7 @@
2020
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
23-
# SECRET_KEY = 'django-insecure-it3=f@6m=cbids$1(mr=0(2#awo#y$!@$^!c41+=3#ag7hn=xl'
23+
# SECRET_KEY = 'django-insecure-=bad%3%tbrw8(ohgu2uyi7)acv!$1br3=j-o)i@b+1d9g-sd1('
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
@@ -31,52 +31,52 @@
3131
# Application definition
3232

3333
INSTALLED_APPS = [
34-
"django.contrib.admin",
35-
"django.contrib.auth",
36-
"django.contrib.contenttypes",
37-
"django.contrib.sessions",
38-
"django.contrib.messages",
39-
"django.contrib.staticfiles",
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
4040
]
4141

4242
MIDDLEWARE = [
43-
"django.middleware.security.SecurityMiddleware",
44-
"django.contrib.sessions.middleware.SessionMiddleware",
45-
"django.middleware.common.CommonMiddleware",
46-
"django.middleware.csrf.CsrfViewMiddleware",
47-
"django.contrib.auth.middleware.AuthenticationMiddleware",
48-
"django.contrib.messages.middleware.MessageMiddleware",
49-
"django.middleware.clickjacking.XFrameOptionsMiddleware",
43+
'django.middleware.security.SecurityMiddleware',
44+
'django.contrib.sessions.middleware.SessionMiddleware',
45+
'django.middleware.common.CommonMiddleware',
46+
'django.middleware.csrf.CsrfViewMiddleware',
47+
'django.contrib.auth.middleware.AuthenticationMiddleware',
48+
'django.contrib.messages.middleware.MessageMiddleware',
49+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5050
]
5151

52-
ROOT_URLCONF = "portfolio.urls"
52+
ROOT_URLCONF = 'portfolio.urls'
5353

5454
TEMPLATES = [
5555
{
56-
"BACKEND": "django.template.backends.django.DjangoTemplates",
57-
"DIRS": [],
58-
"APP_DIRS": True,
59-
"OPTIONS": {
60-
"context_processors": [
61-
"django.template.context_processors.debug",
62-
"django.template.context_processors.request",
63-
"django.contrib.auth.context_processors.auth",
64-
"django.contrib.messages.context_processors.messages",
56+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
57+
'DIRS': [],
58+
'APP_DIRS': True,
59+
'OPTIONS': {
60+
'context_processors': [
61+
'django.template.context_processors.debug',
62+
'django.template.context_processors.request',
63+
'django.contrib.auth.context_processors.auth',
64+
'django.contrib.messages.context_processors.messages',
6565
],
6666
},
6767
},
6868
]
6969

70-
WSGI_APPLICATION = "portfolio.wsgi.application"
70+
WSGI_APPLICATION = 'portfolio.wsgi.application'
7171

7272

7373
# Database
7474
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
7575

7676
DATABASES = {
77-
"default": {
78-
"ENGINE": "django.db.backends.sqlite3",
79-
"NAME": BASE_DIR / "db.sqlite3",
77+
'default': {
78+
'ENGINE': 'django.db.backends.sqlite3',
79+
'NAME': BASE_DIR / 'db.sqlite3',
8080
}
8181
}
8282

@@ -86,26 +86,26 @@
8686

8787
AUTH_PASSWORD_VALIDATORS = [
8888
{
89-
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
89+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
9090
},
9191
{
92-
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
92+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
9393
},
9494
{
95-
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
95+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
9696
},
9797
{
98-
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
98+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
9999
},
100100
]
101101

102102

103103
# Internationalization
104104
# https://docs.djangoproject.com/en/3.2/topics/i18n/
105105

106-
LANGUAGE_CODE = "en-us"
106+
LANGUAGE_CODE = 'en-us'
107107

108-
TIME_ZONE = "UTC"
108+
TIME_ZONE = 'UTC'
109109

110110
USE_I18N = True
111111

@@ -117,13 +117,11 @@
117117
# Static files (CSS, JavaScript, Images)
118118
# https://docs.djangoproject.com/en/3.2/howto/static-files/
119119

120-
STATIC_URL = "/static/"
120+
STATIC_URL = '/static/'
121121

122122
# Default primary key field type
123123
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
124124

125-
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
126-
125+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
127126
import django_heroku
128-
129127
django_heroku.settings(locals())

django-hosting-heroku/source_code_final/portfolio-project/portfolio/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
from django.urls import path
1818

1919
urlpatterns = [
20-
path("admin/", admin.site.urls),
20+
path('admin/', admin.site.urls),
2121
]

django-hosting-heroku/source_code_final/portfolio-project/portfolio/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.wsgi import get_wsgi_application
1313

14-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "portfolio.settings")
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'portfolio.settings')
1515

1616
application = get_wsgi_application()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
asgiref==3.3.4
1+
asgiref==3.4.1
22
dj-database-url==0.5.0
3-
Django==3.2.3
3+
Django==3.2.5
44
django-heroku==0.3.1
5-
psycopg2==2.8.6
5+
psycopg2==2.9.1
66
pytz==2021.1
77
sqlparse==0.4.1
88
whitenoise==5.2.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.9.5
1+
python-3.9.6
Binary file not shown.

0 commit comments

Comments
 (0)