Skip to content

Commit 854ca3a

Browse files
authored
Merge branch 'master' into top-python-game-engines
2 parents ec49853 + 35da9ed commit 854ca3a

File tree

877 files changed

+57113
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

877 files changed

+57113
-69
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version: 2
66
jobs:
77
build:
88
docker:
9-
- image: circleci/python:3.8
9+
- image: circleci/python:3.10
1010

1111
working_directory: ~/repo
1212

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ coverage.xml
5656
# Django stuff:
5757
*.log
5858
local_settings.py
59+
*.sqlite3
60+
nohup.out
5961

6062
# Flask stuff:
6163
instance/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Django Podcast Content Aggregator
2+
3+
> **Note:** The project is built with `Python 3.9.1`, but should work with any version of Python higher than 3.6.
4+
5+
## About This Repository
6+
7+
This is a companion project to the [Build a Content Aggregator in Python](https://realpython.com/build-a-content-aggregator-python/) tutorial on _Real Python_.
8+
Visit the article to follow along or download the content of `source_code_final/` folder from this repository.
9+
10+
## How To Run The Project
11+
12+
Create and activate a [Python virtual environment](https://realpython.com/python-virtual-environments-a-primer/) for your operating system and install the dependencies:
13+
14+
```bash
15+
(.venv) $ python -m pip install -r <path_to_requirements.txt>
16+
```
17+
18+
You can find the `requirements.txt` file in `source_code_setup/requirements.txt`.
19+
20+
Navigate to `source_code_final/` and start the Django development server:
21+
22+
```bash
23+
(.venv) $ cd source_code_final
24+
(.venv) $ python manage.py runserver
25+
```
26+
27+
You can now navigate to `localhost:8000` in your browser and inspect the finished project. You can also take a look at the project at certain steps as described in the associated tutorial.

build-a-django-content-aggregator/source_code_final/content_aggregator/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for content_aggregator project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "content_aggregator.settings")
15+
16+
application = get_asgi_application()
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
"""
2+
Django settings for content_aggregator project.
3+
4+
Generated by 'django-admin startproject' using Django 3.1.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.1/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = "5kk6a_2ynd)yk!+uipwv5j-&!wu3v1e-*$&^*^lc_%tv+5ob4q"
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
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",
40+
# My Apps
41+
"podcasts.apps.PodcastsConfig",
42+
# Third Party Apps
43+
"django_apscheduler",
44+
]
45+
46+
MIDDLEWARE = [
47+
"django.middleware.security.SecurityMiddleware",
48+
"django.contrib.sessions.middleware.SessionMiddleware",
49+
"django.middleware.common.CommonMiddleware",
50+
"django.middleware.csrf.CsrfViewMiddleware",
51+
"django.contrib.auth.middleware.AuthenticationMiddleware",
52+
"django.contrib.messages.middleware.MessageMiddleware",
53+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
54+
]
55+
56+
ROOT_URLCONF = "content_aggregator.urls"
57+
58+
TEMPLATES = [
59+
{
60+
"BACKEND": "django.template.backends.django.DjangoTemplates",
61+
"DIRS": [
62+
BASE_DIR / "templates",
63+
],
64+
"APP_DIRS": True,
65+
"OPTIONS": {
66+
"context_processors": [
67+
"django.template.context_processors.debug",
68+
"django.template.context_processors.request",
69+
"django.contrib.auth.context_processors.auth",
70+
"django.contrib.messages.context_processors.messages",
71+
],
72+
},
73+
},
74+
]
75+
76+
WSGI_APPLICATION = "content_aggregator.wsgi.application"
77+
78+
79+
# Database
80+
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
81+
82+
DATABASES = {
83+
"default": {
84+
"ENGINE": "django.db.backends.sqlite3",
85+
"NAME": BASE_DIR / "db.sqlite3",
86+
}
87+
}
88+
89+
90+
# Password validation
91+
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
92+
93+
AUTH_PASSWORD_VALIDATORS = [
94+
{
95+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
96+
},
97+
{
98+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
99+
},
100+
{
101+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
102+
},
103+
{
104+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
105+
},
106+
]
107+
108+
109+
# Internationalization
110+
# https://docs.djangoproject.com/en/3.1/topics/i18n/
111+
112+
LANGUAGE_CODE = "en-us"
113+
114+
TIME_ZONE = "UTC"
115+
116+
USE_I18N = True
117+
118+
USE_L10N = True
119+
120+
USE_TZ = True
121+
122+
123+
# Static files (CSS, JavaScript, Images)
124+
# https://docs.djangoproject.com/en/3.1/howto/static-files/
125+
126+
STATIC_URL = "/static/"
127+
STATICFILES_DIRS = [
128+
BASE_DIR / "static",
129+
]
130+
131+
# Logging
132+
# https://docs.djangoproject.com/en/3.1/topics/logging/
133+
134+
LOGGING = {
135+
"version": 1,
136+
"disable_existing_loggers": False,
137+
"handlers": {
138+
"console": {
139+
"class": "logging.StreamHandler",
140+
},
141+
},
142+
"root": {
143+
"handlers": ["console"],
144+
"level": "INFO",
145+
},
146+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""content_aggregator URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path, include
18+
19+
urlpatterns = [
20+
path("admin/", admin.site.urls),
21+
path("", include("podcasts.urls")),
22+
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for content_aggregator project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "content_aggregator.settings")
15+
16+
application = get_wsgi_application()
416 KB
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault(
10+
"DJANGO_SETTINGS_MODULE", "content_aggregator.settings"
11+
)
12+
try:
13+
from django.core.management import execute_from_command_line
14+
except ImportError as exc:
15+
raise ImportError(
16+
"Couldn't import Django. Are you sure it's installed and "
17+
"available on your PYTHONPATH environment variable? Did you "
18+
"forget to activate a virtual environment?"
19+
) from exc
20+
execute_from_command_line(sys.argv)
21+
22+
23+
if __name__ == "__main__":
24+
main()

0 commit comments

Comments
 (0)