master 2579fe5d7809 cached
292 files
532.9 KB
125.6k tokens
266 symbols
1 requests
Download .txt
Showing preview only (598K chars total). Download the full file or copy to clipboard to get everything.
Repository: feldroy/two-scoops-of-django-3.x
Branch: master
Commit: 2579fe5d7809
Files: 292
Total size: 532.9 KB

Directory structure:
gitextract_y76tine9/

├── .github/
│   └── FUNDING.yml
├── ISSUE_TEMPLATE
├── README.md
├── changelog.md
└── code/
    ├── chapter_00_example_01.py
    ├── chapter_00_example_02.py
    ├── chapter_01_example_01.py
    ├── chapter_01_example_02.py
    ├── chapter_01_example_03.py
    ├── chapter_01_example_04.py
    ├── chapter_01_example_05.py
    ├── chapter_01_example_06.py
    ├── chapter_01_example_07.py
    ├── chapter_01_example_08.py
    ├── chapter_02_example_01.txt
    ├── chapter_02_example_02.txt
    ├── chapter_03_example_01.txt
    ├── chapter_03_example_02.txt
    ├── chapter_03_example_03.txt
    ├── chapter_03_example_04.txt
    ├── chapter_03_example_05.txt
    ├── chapter_03_example_06.txt
    ├── chapter_03_example_07.txt
    ├── chapter_03_example_08.txt
    ├── chapter_03_example_09.txt
    ├── chapter_03_example_10.txt
    ├── chapter_04_example_01.txt
    ├── chapter_04_example_02.txt
    ├── chapter_04_example_03.py
    ├── chapter_04_example_04.txt
    ├── chapter_04_example_05.py
    ├── chapter_05_example_01.txt
    ├── chapter_05_example_02.txt
    ├── chapter_05_example_03.txt
    ├── chapter_05_example_04.py
    ├── chapter_05_example_05.txt
    ├── chapter_05_example_06.py
    ├── chapter_05_example_07.txt
    ├── chapter_05_example_08.txt
    ├── chapter_05_example_09.txt
    ├── chapter_05_example_10.txt
    ├── chapter_05_example_11.txt
    ├── chapter_05_example_12.txt
    ├── chapter_05_example_13.txt
    ├── chapter_05_example_14.py
    ├── chapter_05_example_15.py
    ├── chapter_05_example_16.py
    ├── chapter_05_example_17.py
    ├── chapter_05_example_18.py
    ├── chapter_05_example_19.json
    ├── chapter_05_example_20.py
    ├── chapter_05_example_21.txt
    ├── chapter_05_example_22.txt
    ├── chapter_05_example_23.txt
    ├── chapter_05_example_24.txt
    ├── chapter_05_example_25.txt
    ├── chapter_05_example_26.txt
    ├── chapter_05_example_27.txt
    ├── chapter_05_example_28.py
    ├── chapter_05_example_29.py
    ├── chapter_05_example_30.py
    ├── chapter_06_example_01.py
    ├── chapter_06_example_02.py
    ├── chapter_06_example_03.py
    ├── chapter_06_example_04.py
    ├── chapter_06_example_05.py
    ├── chapter_06_example_06.py
    ├── chapter_06_example_07.py
    ├── chapter_06_example_08.py
    ├── chapter_06_example_09.py
    ├── chapter_06_example_10.py
    ├── chapter_06_example_11.py
    ├── chapter_07_example_01.py
    ├── chapter_07_example_02.py
    ├── chapter_07_example_03.py
    ├── chapter_07_example_04.py
    ├── chapter_07_example_05.py
    ├── chapter_07_example_06.py
    ├── chapter_07_example_07.py
    ├── chapter_07_example_08.py
    ├── chapter_07_example_09.sql
    ├── chapter_07_example_10.py
    ├── chapter_07_example_11.py
    ├── chapter_08_example_01.py
    ├── chapter_08_example_02.py
    ├── chapter_08_example_03.py
    ├── chapter_08_example_04.py
    ├── chapter_08_example_05.py
    ├── chapter_08_example_06.html
    ├── chapter_08_example_07.py
    ├── chapter_08_example_08.html
    ├── chapter_08_example_09.py
    ├── chapter_08_example_10.py
    ├── chapter_08_example_11.py
    ├── chapter_08_example_12.py
    ├── chapter_08_example_13.py
    ├── chapter_09_example_01.py
    ├── chapter_09_example_02.py
    ├── chapter_09_example_03.py
    ├── chapter_09_example_04.py
    ├── chapter_09_example_05.py
    ├── chapter_09_example_06.py
    ├── chapter_09_example_07.py
    ├── chapter_10_example_01.py
    ├── chapter_10_example_02.py
    ├── chapter_10_example_03.py
    ├── chapter_10_example_04.py
    ├── chapter_10_example_05.py
    ├── chapter_10_example_06.html
    ├── chapter_10_example_07.py
    ├── chapter_10_example_08.py
    ├── chapter_10_example_09.py
    ├── chapter_10_example_10.html
    ├── chapter_10_example_11.py
    ├── chapter_10_example_12.html
    ├── chapter_10_example_13.py
    ├── chapter_10_example_14.py
    ├── chapter_11_example_01.py
    ├── chapter_11_example_02.py
    ├── chapter_11_example_03.py
    ├── chapter_12_example_01.py
    ├── chapter_12_example_02.py
    ├── chapter_12_example_03.py
    ├── chapter_12_example_04.py
    ├── chapter_12_example_05.py
    ├── chapter_12_example_06.py
    ├── chapter_12_example_07.py
    ├── chapter_12_example_08.py
    ├── chapter_12_example_09.py
    ├── chapter_12_example_10.py
    ├── chapter_12_example_11.py
    ├── chapter_12_example_12.py
    ├── chapter_12_example_13.py
    ├── chapter_12_example_14.py
    ├── chapter_12_example_15.py
    ├── chapter_12_example_16.py
    ├── chapter_12_example_17.html
    ├── chapter_12_example_18.html
    ├── chapter_13_example_01.py
    ├── chapter_13_example_02.py
    ├── chapter_13_example_03.html
    ├── chapter_13_example_04.py
    ├── chapter_13_example_05.py
    ├── chapter_13_example_06.py
    ├── chapter_13_example_07.py
    ├── chapter_13_example_08.py
    ├── chapter_13_example_09.py
    ├── chapter_13_example_10.py
    ├── chapter_14_example_01.txt
    ├── chapter_14_example_02.txt
    ├── chapter_14_example_03.txt
    ├── chapter_14_example_04.txt
    ├── chapter_14_example_05.py
    ├── chapter_14_example_06.html
    ├── chapter_14_example_07.py
    ├── chapter_14_example_08.html
    ├── chapter_14_example_09.py
    ├── chapter_14_example_10.html
    ├── chapter_14_example_11.html
    ├── chapter_14_example_12.html
    ├── chapter_14_example_13.html
    ├── chapter_14_example_14.html
    ├── chapter_14_example_15.html
    ├── chapter_14_example_16.html
    ├── chapter_14_example_17.html
    ├── chapter_14_example_18.html
    ├── chapter_14_example_19.html
    ├── chapter_14_example_20.html
    ├── chapter_14_example_21.html
    ├── chapter_14_example_22.html
    ├── chapter_14_example_23.html
    ├── chapter_14_example_24.py
    ├── chapter_15_example_01.html
    ├── chapter_15_example_02.py
    ├── chapter_16_example_01.html
    ├── chapter_16_example_02.py
    ├── chapter_16_example_03.html
    ├── chapter_16_example_04.py
    ├── chapter_16_example_05.html
    ├── chapter_16_example_06.py
    ├── chapter_17_example_01.py
    ├── chapter_17_example_02.py
    ├── chapter_17_example_03.py
    ├── chapter_17_example_04.py
    ├── chapter_17_example_05.py
    ├── chapter_17_example_06.txt
    ├── chapter_17_example_07.txt
    ├── chapter_17_example_08.txt
    ├── chapter_17_example_09.txt
    ├── chapter_17_example_10.py
    ├── chapter_17_example_11.py
    ├── chapter_17_example_12.txt
    ├── chapter_17_example_13.txt
    ├── chapter_17_example_14.txt
    ├── chapter_17_example_15.py
    ├── chapter_17_example_16.py
    ├── chapter_18_example_01.txt
    ├── chapter_18_example_02.txt
    ├── chapter_19_example_01.html
    ├── chapter_21_example_01.py
    ├── chapter_21_example_02.py
    ├── chapter_21_example_03.py
    ├── chapter_21_example_04.py
    ├── chapter_22_example_01.py
    ├── chapter_22_example_02.py
    ├── chapter_22_example_03.py
    ├── chapter_22_example_04.py
    ├── chapter_22_example_05.py
    ├── chapter_22_example_06.py
    ├── chapter_22_example_07.py
    ├── chapter_22_example_08.py
    ├── chapter_22_example_09.py
    ├── chapter_22_example_10.py
    ├── chapter_22_example_11.py
    ├── chapter_22_example_12.py
    ├── chapter_23_example_01.txt
    ├── chapter_23_example_02.txt
    ├── chapter_23_example_03.txt
    ├── chapter_23_example_04.txt
    ├── chapter_23_example_05.txt
    ├── chapter_23_example_06.txt
    ├── chapter_23_example_07.txt
    ├── chapter_23_example_08.txt
    ├── chapter_23_example_09.txt
    ├── chapter_23_example_10.txt
    ├── chapter_23_example_11.txt
    ├── chapter_24_example_01.txt
    ├── chapter_24_example_02.py
    ├── chapter_24_example_03.py
    ├── chapter_24_example_04.py
    ├── chapter_24_example_05.py
    ├── chapter_24_example_06.py
    ├── chapter_24_example_07.py
    ├── chapter_24_example_08.txt
    ├── chapter_24_example_09.txt
    ├── chapter_24_example_10.txt
    ├── chapter_24_example_11.py
    ├── chapter_25_example_01.txt
    ├── chapter_25_example_02.txt
    ├── chapter_28_example_01.py
    ├── chapter_28_example_02.txt
    ├── chapter_28_example_03.py
    ├── chapter_28_example_04.py
    ├── chapter_28_example_05.py
    ├── chapter_28_example_06.py
    ├── chapter_28_example_07.py
    ├── chapter_28_example_08.py
    ├── chapter_28_example_09.py
    ├── chapter_28_example_10.py
    ├── chapter_28_example_11.html
    ├── chapter_28_example_12.html
    ├── chapter_29_example_01.py
    ├── chapter_29_example_02.py
    ├── chapter_29_example_03.py
    ├── chapter_29_example_04.py
    ├── chapter_29_example_05.py
    ├── chapter_29_example_06.py
    ├── chapter_30_example_01.py
    ├── chapter_30_example_02.py
    ├── chapter_30_example_03.txt
    ├── chapter_31_example_01.txt
    ├── chapter_31_example_02.py
    ├── chapter_31_example_03.py
    ├── chapter_31_example_04.py
    ├── chapter_31_example_05.py
    ├── chapter_31_example_06.py
    ├── chapter_31_example_07.py
    ├── chapter_31_example_08.py
    ├── chapter_31_example_09.py
    ├── chapter_31_example_10.py
    ├── chapter_31_example_11.py
    ├── chapter_35_example_01.txt
    ├── chapter_35_example_02.py
    ├── chapter_35_example_03.py
    ├── chapter_35_example_04.html
    ├── chapter_35_example_05.py
    ├── chapter_35_example_06.py
    ├── chapter_35_example_07.py
    ├── chapter_35_example_08.py
    ├── chapter_39_example_01.txt
    ├── chapter_39_example_02.txt
    ├── chapter_39_example_03.txt
    ├── chapter_39_example_04.txt
    ├── chapter_39_example_05.txt
    ├── chapter_39_example_06.txt
    ├── chapter_39_example_07.txt
    ├── chapter_39_example_08.txt
    ├── chapter_41_example_01.py
    ├── chapter_41_example_02.py
    ├── chapter_41_example_03.py
    ├── chapter_41_example_04.py
    └── chapter_41_example_05.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms

github: [pydanny]
patreon: feldroy
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']


================================================
FILE: ISSUE_TEMPLATE
================================================
## Greetings! 

Hello! As a reader, you're encouraged to submit bug reports to us for errors that you find. In turn we will give you credit for your contributions in not just the e-book but also in the print paperback. This is your opportunity to have your name in one of our books as a contributor, which you are then welcome to add to your resume and LinkedIn profile.

Notes:

- TODOs are markers to let you know we are going to expand an area, so reporting them during the ALPHA and BETA period **doesn't** qualify as an attributable item.
- `??:??` are references for areas written but still being examined by our reviewers and not yet in the published version of the book. Reporting them **doesn't** qualify as an attributable item.

## Location within the Book

* Chapter or Appendix:
* Section:
* Subsection:

Hint: Page numbers change all the time. The best way to report an issue is by chapter, section, and subsection numbers.

## Description 

> If grammar, enter problematic text here, otherwise delete this line.

```
If code-related, enter it within these backticks. Otherwise, delete this segment.
```

## Possible Solutions

## Your full name so we can provide accurate credit within the book


================================================
FILE: README.md
================================================
# Two Scoops of Django 3.x
The issue tracker, changelog, and code repository for Two Scoops of Django 3.x

Tracking thoughts and feature requests for Two Scoops of Django 3.x in the issue tracker.

Available currently in PDF formats at https://www.feldroy.com/products/two-scoops-of-django-3-x. 

## Before You Submit an Issue

* Be nice. :-)
* Be honest.
* Check the issues from the previous version (1.11) [open](https://github.com/twoscoops/two-scoops-of-django-1.11/issues?state=open) and [closed](https://github.com/twoscoops/two-scoops-of-django-1.11/issues?state=closed) to see if your issue already exists.
* Check the [changelog](https://github.com/feldroy/two-scoops-of-django-3.x/blob/master/changelog.md) to see if your issue has already been resolved.
* Please, please, please identify each issue by chapter, section, and subsection numbers. Since the content shifts around using page numbers to identify problems is innaccurate.
* For tracking and credit purposes, **each request for correction needs to be in it's own issue. If an issue contains 2 or more issues, we may close it with a request for breaking up into more atomic issues.**

**Editorial Note:** In order to make issues more readily searchable, we may alter titles and descriptions of issues as needed.

## When will this be published?

It's published and you can get it at https://www.feldroy.com/products/two-scoops-of-django-3-x


================================================
FILE: changelog.md
================================================
# Two Scoops of Django Changelog

This lists many, but not all the changes between TSD 1.11 and TSD 3.x.

# Updates 2023-08-16

## General

- Grammar corrections
- Cleanup frontmatter
- Zappa now pointing at github.com/zappa/zappa

## Asynchronous Views

- Finally admit that the Django 3 story for Asynchronous views was still in its infancy.

## GraphQL

- Recommend Strawberry as best-of-breed Python GraphQL libraries
- Mention https://github.com/mirumee/ariadne-codegen for client generation

## Acknowledgements

- Give special thanks to Fábio C. Barrionuevo 
- Add link to Laura Gelsomino's LinkedIn profile

# Updates until 2021-07-08

## General

- Grammar corrections
- All form classes have `fields` defined

## Javascript

- Added Next and Nuxt
- Linked to Django support for HTMX and Hotwire
- General cleanup

## GraphQL

- Make Graphene a first class citizen
- Discuss Ariadne's shortcomings

## Signals

- Updated signals to Django 3.2

## PAAS

- Added render.com and divio cloud
- Remove mention of Heroku

## Deployment

- Added ASGI
- Modernized WSGI section

## Queues

- Removed django-background-tasks as it is now unmaintained
- Edit, cleanup, and unleash remaining content after subsection 1.3.5

## Continuous Integration

- Updated CI to Django 3.2

# Updates until 2021-06-14

## General

- Changed our names to Daniel and Audrey Roy Greenfeld
- Grammar and spelling corrections
- Corrected broken links across the book

## PAAS

- Add Digital Ocean App Platform
- Be honest about Heroku so users see it with open eyes

## Debugging

- Brought chapter in
- Removed link to ancient blog post
- Added mention of `breakpoint()`

## Where and how to ask for help

- Added section on the official forums
- Added Libera Chat IRC
- Linkified a few items to make things easier on readers

---

# Updates until 2021-01-27

## General

- Converted all docs links to point to Django 3.2

## Coding Style

- Changed `isort` tip box to a package tip

## Graphql

- Removed trygql.com

## Security

- Mention OTPs in 2FA

## Logging

- Chapter has been revised and is available for readers!
- Added warning box about using f-strings with loggers
- Removed Python 2 mention

## Packages

- Added aldjemy
- Added django-stronghold
- Added environment variable section with multiple packages

---

# Updates until 2020-12-02

## General Changes

- Added Authorized Vendors and Distributors informations
- Various spelling and grammar corrections
- Removed last python 2.7-style usages of `super()`

## Database Queries

- Use `breakpoint()` instead of importing pdb

## FBVs

- Added Luke Plant's "Django Views the Right Way"

## User models

- Corrected wrong parent class

---

# Updates until 2020-07-27

## General Changes

- Grammar fixes

## Settings and Requirements

- Add missing `ql` to ORM engine

## Models and Queries

- JSONField is now for all database types

## Templates

- Removed GitHub's 404 page from the list of being self-contained HTML, CSS, and JS

## Third-party packages

- Fix code highlighting

## Security

- Fix borked link

## Appendix: Resources

- Added testdriven.io

---

# Updates until 2020-07-09

## General Changes

- Moved first reference to indexes from chapter 6 to chapter 7
- The inevitable grammar corrections

## Settings and Requirements

- Added `.zshrc` for configuring environment variables

## Best Practices for FBVs

- Made use of `functools.wraps` consistent

## Best Practices for CBVs

- Mixins should not inherit from `object`, that is a holdover from Python 2.7

## Finding and Reducing bottlenecks

- Reviewed content in full and added to the book

## Third-Party Packages

- Add instruction for git tagging project releases

## Async Task Queues

- Started on reviewing content

## Internationalization

- All pages updated for Django 3.x and Python 3.8

---

# Updates until 2020-07-07

This update adds 15 new pages to Two Scoops of Django, bringing us up to 461!

## General Changes

- Yet more grammar fixes

## Javascript

- Added quote by DHH about the state of JavaScript in 2020

## Admin chapter

- Removed mention of long deprecated `allow_tags` property descriptor
- Add warning box to use `format_html` function for enhancing security

## User model chapter

- Added multiple user models
- Demonstration of proxy models

## Package Used in this Book Appendix

- Out of "being updated mode"
- Reviewed all packages
- Added new packages
- Removal of deprecated packages

# Updates until 2020-06-16

## General Changes

- Revised and legible bad code examples!
- More grammar fixes
- All use of `reverse()` function now include URL namespaces

## Coding Standards

- Change focus of `Use Explicit Relative Imports` to `Understand Explicit Relative Imports` and removed `Implicit Relative Imports`

## Chapter - Settings and Requirements

- Removed tipbox for `Using django-admin Instead of manage.py`. This advice has been removed from the Django docs

## Chapter - Database Model Best Practices

- Removed link to blog post that used to describe how to use `DateTimeField` with logical deletes

## Chapter - Building APIs with Django Rest Framework

- Added references to OpenAPI and tools
- Mentioned using vanilla Django for creating APIs
- Converted package tip for django-tastypie and django-jsonview into a new section for DRF alternatives
- Added trailing 'r' on `rest_framework.permissions.IsAdminUser`

## Chapter - JavaScript

- Changed section "Popular JavaScript Frameworks" to "Popular JavaScript Approaches"
- Added description list for serverside rendering of templates
- Included alpine.js and turbolinks
- Added section on JSON encoding for data rendered in the template but consumed by JavaScript

## Chapter - Security

- Corrected typo so PHI is now the acronym for `Protected Health Information`

## Acknowledgements

- Added Bio for Haris Ibrahim

---

# Updates until 2020-06-05

- Included forward by [Will Vincent](https://learndjango.com)
- Began expanding the async views chapter
- Made pipenv active again now that they had a formal release
- Added first half of Appendix A: Chapters mentioned in this book

---

# Updates until 2020-05-29

## General

- Model mommy is now model bakery

## Chapter - Models

- Table layout corrections in chapter 6
- `BooleanField(null=True)` recommended instead of `NullBooleanField`

## Chapter - FBVs

- Corrected return type for `check_sprinkles` function

## Chapter - Django REST Framework

- Link to sources on how to rate limit
- Removed material on coreapi because that project has been replaced by openapi

## Chapter - Documentation

- Added myst for rendering markdown in Sphinx

## Chapter - User Model

- Mention that django-authtools doesn't yet work for Django 3

## Chapter - Security

- Ponycheckup is no more. Many thanks to Sasha Romijn for providing such an invaluable
- Added PyCharm Django Security

---

# Updates until 2020-05-19

## General

- More grammar!
- Consistent case for `URLConfs`

## Chapter - Environment Setup

- Replaced "typing" with "type casting", the latter is more explicit

## Chapter - Project Setup

- Added link to Cookiecutter docs

## Chapter - Databases

- Took out the long removed `use_for_related_fields` attribute from manager code example

## Chapter - Templates

- Fix LaTeX escape failure

## Chapter - Security

- Removed Pony Checkup

## Chapter - PaaS

- Added Zappa as an option
- Took away statement that Elastic Beanstalk was on mod_wsgi and hence no channels

## Chapter - CI

- Added MacOS to Azure Pipelines in feature table

## Chapter - Debugging

- Updated IDE preferences

---

# Updates until 2020-05-13

## General changes

- General grammar and spelling improvements
- Updated Django version to 3.x
- Updated Python version to Python 3.8/3.9
- Removed Appendix giving advice on upgrading from Python 2 to 3
- Remove mention of Mercurial.
- Changed `README.rst` to `README.md`
- `OS X` is now `Mac`
- References to `django-admin.py` replace with `django-admin`
- Changed pypi.python.org to pypi.org
- Removed last vestige of `Twitter Bootstrap` in favor of `Bootstrap`
- Due to problems with a number of PDF renderers on the Mac URL escaping '#' incorrectly, URLs with '#" are forwarded through our `feld.to` link shortener. The reader sees the correct URL, but clicking links takes them through feld.to.
- "Don't Do This!!" code examples have new style
- Use "README file" instead of README.md or README.rst
- Added footer to instruct users where to submit issues
- Added warnings at the front of chapters which won't be published

## Book crafting process

- LaTeX datestamping now automated. Why didn't we do this years ago?
- Added placeins LaTex package to the `requirements-latex.yml` file.
- Updated the book build instructions.

## Note from the authors

- Added Sentry
- Remove Pinterest from company list

## Introduction

- Removed apocryphal statement by Leonardo Da Vinci
-

## Chapter - Coding Style

- Added quote from "Structure and Interpretation of Computer Programs"
- Removed duplicate URL
- Added black
- Added wemake-python-styleguide
- Added isort for ordering imports
- Change JS coding style standard URL to github.com/standard/standard

## Chapter - Environment Setup

- Added mention of poetry, conda, and pipenv
- Git is now the only tool for version control
- Added Docker to summary
- Warn that pip doesn't necessarily come with Python installations on Linux distros
- Removed mention of `easy_install`

## Chapter - Settings and Requirements

- Use of `json.load` instead of `json.loads`

## Chapter - Django Project Layout

- Added "Don't Upload Environment Directories To Open Source" warning box
- Now calls runserver with the correct settings argument
- Removed wemake-python-styleguide as a recommendation for Django projects

## Chapter - Fundamentals of App Design

- Removed extra `models.py` from app layout example
- Added Tom Christie's article for refuting the service layer approach to organizing business logic

## Chapter - Database/Model Best Practices

- Rewrote the enumeration types segment as Django now includes them as part of core
- Mention `BooleanField` has default of `blank=True`
- Added Haki Benita's excellent article on bullet proofing Django models
- `null=True` for `ManyToManyField` is now recommended against as it raises a check warning
- Custom default Model Managers are no longer forbidden, just an advanced technique to be wary of
- Removed mention of South as a competing migrations system

## Chapter - More Forms

- Added links to more useful references, removed some outdated ones
- Switch from JWT library to dj-rest-auth for authentication
- Remove link to csrf docs

## Chapter - Function- and Class-Based Views

- Removed historical note from Django 1.5 era about not removing function-based views
- Now using `path()` url route declarations instead of the old `url()` function

## Chapter - Function-Based Views

- Added type annotations to views

## Chapter - Class-Based Views

- Added type annotations to views
- Flavor model now uses enumeration choices
- Advice on Mixins inheritance clarified for Python 3
- Added Serafeim Papastefanos' excellent CBV post to the resources section
- Added links to more useful references, removed some outdated ones

## Chapter - Asynchronous Views

- Added stub chapter

## Chapter - Templates

- Made Python code example more concise
- HTML/DTL examples now use 2-space examples
- Removed Python 2 era mention that `super()` accepts arguments

## Chapter - Template Tags

- Marked django-wysiwyg as deprecated

## Chapter - Jinja2

- Removed statement about maturity of Jinja2 in Django, it's mature now
- Switched to 2 character tabs

## Chapter - Django REST Framework

- Make more explicit that routers go into `urls.py` modules
- Mention Randall Degges advice about Usage-Based Plans
- Mention DRF support for different versioning schemas and link to docs
- Fixed link to Classy DRF site

## Chapter - Building GraphQL APIs with Graphene

- New chapter!

## Chapter - JavaScript and Django

- Changed the name from **Consuming REST APIs** to **JavaScript and Django**
- Restructured to be about JavaScript in the Django domain, with REST APIs being a topic
- Added Vanilla JS as progressive option
- Moved JQuery to legacy. While, JQuery isn't legacy yet it is on the way to become so
- Rewrote strengthening JavaScript skills
- Removed section on `CSRF_COOKIE_HTTPONLY` as it doesn't make Django any more secure, just satisfies some security auditors.
- No longer recommend JWT as an authentication method
- No longer excuse turning off CSRF to support JWT

## Chapter - FrankenDjango

- Added https://daniel.feldroy.com/when-to-use-mongodb-with-django.html
- Made Kevin Systrom a co-founder of Instagram instead of CEO

## Chapter - Django Admin

- Removed `python_2_unicode_compatible` from the example model

## Chapter - Third Party Packages

- Switched from cookiecutter-pypackage to cookiecutter-pylibrary
- Switched from `.txt` and `.rst` doc extensions to `.md`
- Removed link to Jeff Knupp's excellent article on open sourcing projects as it is unfortunately out of date
- For Twine, replaced "non-ssh" with "non-secure"

## Chapter - Bottlenecks

- Replaced django-johnnycache and django-cache-machine with django-cacheops
- Removed yslow
- Change link to Lanyrd search for conference talks to YouTube
- Removed link to David Cramer's now defunct blog
- Reference Andrew Brook's excellent book, [The Temple of Django Database Performance](https://spellbookpress.com/books/temple-of-django-database-performance/)

## Chapter - Signals

- Added `on_delete` argument to foreign key example

## Chapter - User Model

- Added methods for differint user types

## Chapter - Testing

- Added assertRaisesMessage
- Added assertInHTML
- Added assertURLEqual
- Removed the defunct requestb.in
- Added Postman
- Added interrogate

## Chapter - Documentation

- Removed advising the global installation of Sphinx
- Switch to recommending Markdown over reStructuredText
- Provide reStructuredText as the older alternative
- Remove segment on converting reStructuredText to Markdown
- Added tipbox for other markdown doc site renderers
- Added interrogate

## Chapter - Bottlenecks

- Changed `ATOMIC_REQUESTS` to `False`

## Chapter - Security

_Many thanks to our incredibly diligent security reviewers!_

- Fixed borked link to Security Failures Chapter
- Added warningbox that Let's Encrypt is the most secure option (in progress of being rewritten)
- Added warningbox that not having HTTPS/SSL is inexescusable in 2020
- CSP report submitting is optional per the spec
- Made call for SSL very strident
- Added cloudflare as a free option for SSL
- Mentioned big cloud providers for SSL options
- Remove Sasha Romijn's Pony Checkup. Wonderful tool and we thank her for all those years of supporting Django.
- ALLOWED_HOSTS and DEBUG=True now throws 400 errors
- `IceCreamPayment` model's UUID switched from `db_index=True` to `unique=True`
- Discussion of `SECRET_KEY` now states what can actually occur
- Added section on not storing unnecessary data which includes credit card, PII, and PHI data
- Added missing 'N' to the word 'ever'
- Added section on upgrading password hasher to Argon2
- Added section on using SRI when loading static assets from external CDNs

## Chapter - Utilities

- Removed `django.utils.six`, we're in Python 3 land now!

## Chapter - Deployment

- Removed mention of `mod_python`
- Removed reference to very old versions of `mod_wsgi` (3.3 or less)
- Removed `--no-site-packages` from virtualenv

## Chapter - Continuous Integration

- Removed Python version column from CI-as-a-Service table and replaced with ``operating systems''
- Added Circle CI, GitHub Actions, Azure Pipelines, and Drone

## Chapter - Debugging

- Removed defunct django-gargoyle package and added django-flags as the plucky newcomer

## Appendix - Packages

- Separated Dependency Management out of Core into own category
- Added MkDocs
- Added markdown as option to Sphinx
- Fixed link to Channels

## Appendix - i18n

- Replace `string_concat` with `format_lazy`

## Appendix - Additional resources

- Added Simple Better Than Complex, apologies to Vitor we didn't include it at launch
- Added classy Django forms
- Removed links to our own pages of additional resources

## Appendix - Handling Security Failures

- Removed django-maintenaincemode as it hasn't been updated yet to Django 3
- Removed django-maintenancemode-2 as it could create a false sense of security. Per the security reviewer: "that's not a solution, because if your Django installation is compromised, attackers can turn the maintenance mode off again."

# Appendix - Security Settings

- Made SMTP as SSL mandatory
- ALLOWED_HOSTS and DEBUG=True now throws CommandError

# Appendix - Websockets with Channels

- Removed "Channels Works Better With Python 3.6+". Django 3 makes Python 3.6 or higher mandatory
- Fix broken link to Channels' testing documentation


================================================
FILE: code/chapter_00_example_01.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

class Scoop:
    def __init__(self):
        self._is_yummy = True


================================================
FILE: code/chapter_00_example_02.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

class Scoop:
    def __init__(self):
        self._is_yummy = False


================================================
FILE: code/chapter_01_example_01.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Stdlib imports
from math import sqrt
from os.path import abspath

# Core Django imports
from django.db import models
from django.utils.translation import gettext_lazy as _

# Third-party app imports
from django_extensions.db.models import TimeStampedModel

# Imports from your apps
from splits.models import BananaSplit


================================================
FILE: code/chapter_01_example_02.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# cones/views.py
from django.views.generic import CreateView

# Relative imports of the 'cones' package
from .models import WaffleCone
from .forms import WaffleConeForm

# absolute import from the 'core' package
from core.views import FoodMixin

class WaffleConeCreateView(FoodMixin, CreateView):
    model = WaffleCone
    form_class = WaffleConeForm


================================================
FILE: code/chapter_01_example_03.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django import forms
from django.db import models


================================================
FILE: code/chapter_01_example_04.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# ANTI-PATTERN: Don't do this!
from django.forms import *
from django.db.models import *


================================================
FILE: code/chapter_01_example_05.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# ANTI-PATTERN: Don't do this!
from django.db.models import CharField
from django.forms import CharField


================================================
FILE: code/chapter_01_example_06.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.db.models import CharField as ModelCharField
from django.forms import CharField as FormCharField


================================================
FILE: code/chapter_01_example_07.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

patterns = [
    path(route='add/',
        view=views.add_topping,
        name='add-topping'),
    ]


================================================
FILE: code/chapter_01_example_08.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

patterns = [
    path(route='add/',
        view=views.add_topping,
        name='toppings:add_topping'),
    ]


================================================
FILE: code/chapter_02_example_01.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

$ source ~/.virtualenvs/twoscoops/bin/activate


================================================
FILE: code/chapter_02_example_02.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

$ workon twoscoops


================================================
FILE: code/chapter_03_example_01.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

django-admin startproject mysite
cd mysite
django-admin startapp my_app


================================================
FILE: code/chapter_03_example_02.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

mysite/
├── manage.py
├── my_app
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
└── mysite
    ├── __init__.py
    ├── asgi.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py


================================================
FILE: code/chapter_03_example_03.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

<repository_root>/
├── <configuration_root>/
├── <django_project_root>/


================================================
FILE: code/chapter_03_example_04.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

  icecreamratings_project
  ├── config/
  │   ├── settings/
  │   ├── __init__.py
  │   ├── asgi.py  
  │   ├── urls.py
  │   └── wsgi.py
  ├── docs/
  ├── icecreamratings/
  │   ├── media/  # Development only!
  │   ├── products/
  │   ├── profiles/
  │   ├── ratings/
  │   ├── static/
  │   └── templates/
  ├── .gitignore
  ├── Makefile
  ├── README.md
  ├── manage.py
  └── requirements.txt


================================================
FILE: code/chapter_03_example_05.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

~/projects/icecreamratings_project/
~/.envs/icecreamratings/


================================================
FILE: code/chapter_03_example_06.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

c:\projects\icecreamratings_project\
c:\envs\icecreamratings\


================================================
FILE: code/chapter_03_example_07.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

  ~/.virtualenvs/icecreamratings/


================================================
FILE: code/chapter_03_example_08.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

$ pip freeze


================================================
FILE: code/chapter_03_example_09.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

$ pip freeze > requirements.txt


================================================
FILE: code/chapter_03_example_10.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

cookiecutter https://github.com/pydanny/cookiecutter-django
You've downloaded /home/quique/.cookiecutters/cookiecutter-django before. Is it okay to delete and re-download it? [yes]: no
Do you want to re-use the existing version? [yes]: yes
project_name [My Awesome Project]: icecreamratings
project_slug [icecreamratings]: 
description [Behold My Awesome Project!]: Support your Ice Cream Flavour!
author_name [Daniel Roy Greenfeld]:
<snip for brevity>   


================================================
FILE: code/chapter_04_example_01.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

# Common modules
scoops/
├── __init__.py
├── admin.py
├── apps.py
├── forms.py
├── management/
├── migrations/
├── models.py
├── templatetags/
├── tests/
├── urls.py
├── views.py


================================================
FILE: code/chapter_04_example_02.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

# uncommon modules
scoops/
├── api/
├── behaviors.py
├── constants.py
├── context_processors.py
├── decorators.py
├── db/
├── exceptions.py
├── fields.py
├── factories.py
├── helpers.py
├── managers.py
├── middleware.py
├── schema.py
├── signals.py
├── utils.py
├── viewmixins.py


================================================
FILE: code/chapter_04_example_03.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

class UserManager(BaseUserManager):
    """In users/managers.py"""
    def create_user(self, email=None, password=None, avatar_url=None):
        user = self.model(
            email=email,
            is_active=True,
            last_login=timezone.now(),
            registered_at=timezone.now(),
            avatar_url=avatar_url
        )
        resize_avatar(avatar_url)
        Ticket.objects.create_ticket(user)
        return user

class TicketManager(models.manager):
    """In tasks/managers.py"""
    def create_ticket(self, user: User):
        ticket = self.model(user=user)
        send_ticket_to_guest_checkin(ticket)
        return ticket


================================================
FILE: code/chapter_04_example_04.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

# Service layer example
scoops/
├── api/
├── models.py
├── services.py  # Service layer location for business logic
├── selectors.py  # Service layer location for queries
├── tests/


================================================
FILE: code/chapter_04_example_05.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# In users/services.py
from .models import User
from tickets.models import Ticket, send_ticket_to_guest_checkin

def create_user(email: str, password: str, avatar_url: str) -> User:
    user = User(
        email=email,
        password=password,
        avatar_url=avatar_url
    )
    user.full_clean()
    user.resize_avatar()
    user.save()

    ticket = Ticket(user=user)
    send_ticket_to_guest_checkin(ticket)
    return user


================================================
FILE: code/chapter_05_example_01.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

settings/
├── __init__.py
├── base.py
├── local.py
├── staging.py
├── test.py
├── production.py


================================================
FILE: code/chapter_05_example_02.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

  python manage.py shell --settings=config.settings.local


================================================
FILE: code/chapter_05_example_03.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

python manage.py runserver --settings=config.settings.local


================================================
FILE: code/chapter_05_example_04.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from .base import *

DEBUG = True

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'twoscoops',
        'HOST': 'localhost',
    }
}

INSTALLED_APPS += ['debug_toolbar', ]


================================================
FILE: code/chapter_05_example_05.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

python manage.py runserver --settings=config.settings.local


================================================
FILE: code/chapter_05_example_06.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# settings/local_pydanny.py
from .local import *

# Set short cache timeout
CACHE_TIMEOUT = 30


================================================
FILE: code/chapter_05_example_07.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

settings/
    __init__.py
    base.py
    local_audreyr.py
    local_pydanny.py
    local.py
    staging.py
    test.py
    production.py


================================================
FILE: code/chapter_05_example_08.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

export SOME_SECRET_KEY=1c3-cr3am-15-yummy
export AUDREY_FREEZER_KEY=y34h-r1ght-d0nt-t0uch-my-1c3-cr34m


================================================
FILE: code/chapter_05_example_09.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

> setx SOME_SECRET_KEY 1c3-cr3am-15-yummy


================================================
FILE: code/chapter_05_example_10.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

[Environment]::SetEnvironmentVariable('SOME_SECRET_KEY',
                                    '1c3-cr3am-15-yummy', 'User')
[Environment]::SetEnvironmentVariable('AUDREY_FREEZER_KEY',
                    'y34h-r1ght-d0nt-t0uch-my-1c3-cr34m', 'User')


================================================
FILE: code/chapter_05_example_11.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

[Environment]::SetEnvironmentVariable('SOME_SECRET_KEY',
                                '1c3-cr3am-15-yummy', 'Machine')
[Environment]::SetEnvironmentVariable('AUDREY_FREEZER_KEY',
                'y34h-r1ght-d0nt-t0uch-my-1c3-cr34m', 'Machine')


================================================
FILE: code/chapter_05_example_12.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

unset SOME_SECRET_KEY
unset AUDREY_FREEZER_KEY


================================================
FILE: code/chapter_05_example_13.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

[Environment]::UnsetEnvironmentVariable('SOME_SECRET_KEY', 'User')
[Environment]::UnsetEnvironmentVariable('AUDREY_FREEZER_KEY', 'User')


================================================
FILE: code/chapter_05_example_14.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

>>> import os
>>> os.environ['SOME_SECRET_KEY']
'1c3-cr3am-15-yummy'


================================================
FILE: code/chapter_05_example_15.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Top of settings/production.py
import os
SOME_SECRET_KEY = os.environ['SOME_SECRET_KEY']


================================================
FILE: code/chapter_05_example_16.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# settings/base.py
import os

# Normally you should not import ANYTHING from Django directly
# into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured

def get_env_variable(var_name):
    """Get the environment variable or return exception."""
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = 'Set the {} environment variable'.format(var_name)
        raise ImproperlyConfigured(error_msg)


================================================
FILE: code/chapter_05_example_17.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

SOME_SECRET_KEY = get_env_variable('SOME_SECRET_KEY')


================================================
FILE: code/chapter_05_example_18.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

django.core.exceptions.ImproperlyConfigured: Set the SOME_SECRET_KEY
environment variable.


================================================
FILE: code/chapter_05_example_19.json
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

{
  "FILENAME": "secrets.json",
  "SECRET_KEY": "I've got a secret!",
  "DATABASES_HOST": "127.0.0.1",
  "PORT": "5432"
}


================================================
FILE: code/chapter_05_example_20.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# settings/base.py
import json

# Normally you should not import ANYTHING from Django directly
# into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured

# JSON-based secrets module
with open('secrets.json') as f:
    secrets = json.load(f)

def get_secret(setting, secrets=secrets):
    '''Get the secret variable or return explicit exception.'''
    try:
        return secrets[setting]
    except KeyError:
        error_msg = 'Set the {0} environment variable'.format(setting)
        raise ImproperlyConfigured(error_msg)

SECRET_KEY = get_secret('SECRET_KEY')


================================================
FILE: code/chapter_05_example_21.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

requirements/
├── base.txt
├── local.txt
├── staging.txt
├── production.txt


================================================
FILE: code/chapter_05_example_22.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

Django==3.2.0
psycopg2-binary==2.8.8
djangorestframework==3.11.0


================================================
FILE: code/chapter_05_example_23.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

-r base.txt # includes the base.txt requirements file

coverage==5.1
django-debug-toolbar==2.2


================================================
FILE: code/chapter_05_example_24.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

-r base.txt # includes the base.txt requirements file

coverage==5.1


================================================
FILE: code/chapter_05_example_25.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

-r base.txt # includes the base.txt requirements file


================================================
FILE: code/chapter_05_example_26.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

pip install -r requirements/local.txt


================================================
FILE: code/chapter_05_example_27.txt
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

pip install -r requirements/production.txt


================================================
FILE: code/chapter_05_example_28.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# settings/base.py

# Configuring MEDIA_ROOT
# DON’T DO THIS! Hardcoded to just one user's preferences
MEDIA_ROOT = '/Users/pydanny/twoscoops_project/media'

# Configuring STATIC_ROOT
# DON’T DO THIS! Hardcoded to just one user's preferences
STATIC_ROOT = '/Users/pydanny/twoscoops_project/collected_static'

# Configuring STATICFILES_DIRS
# DON’T DO THIS! Hardcoded to just one user's preferences
STATICFILES_DIRS = ['/Users/pydanny/twoscoops_project/static']

# Configuring TEMPLATES
# DON’T DO THIS! Hardcoded to just one user's preferences
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        DIRS: ['/Users/pydanny/twoscoops_project/templates',]
    },
]


================================================
FILE: code/chapter_05_example_29.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# At the top of settings/base.py
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent.parent
MEDIA_ROOT = BASE_DIR / 'media'
STATIC_ROOT = BASE_DIR / 'static_root'
STATICFILES_DIRS = [BASE_DIR / 'static']
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
    },
]


================================================
FILE: code/chapter_05_example_30.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# At the top of settings/base.py
from os.path import abspath, dirname, join

def root(*dirs):
    base_dir = join(dirname(__file__), '..', '..')
    return abspath(join(base_dir, *dirs))

BASE_DIR = root()
MEDIA_ROOT = root('media')
STATIC_ROOT = root('static_root')
STATICFILES_DIRS = [root('static')]
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [root('templates')],
    },
]


================================================
FILE: code/chapter_06_example_01.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.db import models

class TimeStampedModel(models.Model):
    """
    An abstract base class model that provides self-
    updating ``created`` and ``modified`` fields.
    """
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


================================================
FILE: code/chapter_06_example_02.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

class Meta:
    abstract = True


================================================
FILE: code/chapter_06_example_03.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# flavors/models.py
from django.db import models

from core.models import TimeStampedModel

class Flavor(TimeStampedModel):
    title = models.CharField(max_length=200)


================================================
FILE: code/chapter_06_example_04.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.db import migrations, models

def add_cones(apps, schema_editor):
    Scoop = apps.get_model('scoop', 'Scoop')
    Cone = apps.get_model('cone', 'Cone')

    for scoop in Scoop.objects.all():
        Cone.objects.create(
            scoop=scoop,
            style='sugar'
        )

class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('scoop', '0051_auto_20670724'),
    ]

    operations = [
        migrations.CreateModel(
            name='Cone',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                    serialize=False, verbose_name='ID')),
                ('style', models.CharField(max_length=10),
                    choices=[('sugar', 'Sugar'), ('waffle', 'Waffle')]),
                ('scoop', models.OneToOneField(null=True, to='scoop.Scoop'
                    on_delete=django.db.models.deletion.SET_NULL, )),
            ],
        ),
        # RunPython.noop does nothing but allows reverse migrations to occur
        migrations.RunPython(add_cones, migrations.RunPython.noop)
    ]


================================================
FILE: code/chapter_06_example_05.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# orders/models.py
from django.db import models

class IceCreamOrder(models.Model):
    FLAVOR_CHOCOLATE = 'ch'
    FLAVOR_VANILLA = 'vn'
    FLAVOR_STRAWBERRY = 'st'
    FLAVOR_CHUNKY_MUNKY = 'cm'

    FLAVOR_CHOICES = (
        (FLAVOR_CHOCOLATE, 'Chocolate'),
        (FLAVOR_VANILLA, 'Vanilla'),
        (FLAVOR_STRAWBERRY, 'Strawberry'),
        (FLAVOR_CHUNKY_MUNKY, 'Chunky Munky')
    )

    flavor = models.CharField(
        max_length=2,
        choices=FLAVOR_CHOICES
    )


================================================
FILE: code/chapter_06_example_06.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

>>> from orders.models import IceCreamOrder
>>> IceCreamOrder.objects.filter(flavor=IceCreamOrder.FLAVOR_CHOCOLATE)
[<icecreamorder: 35>, <icecreamorder: 42>, <icecreamorder: 49>]


================================================
FILE: code/chapter_06_example_07.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.db import models

class IceCreamOrder(models.Model):
    class Flavors(models.TextChoices):
        CHOCOLATE = 'ch', 'Chocolate'
        VANILLA = 'vn', 'Vanilla'
        STRAWBERRY = 'st', 'Strawberry'
        CHUNKY_MUNKY = 'cm', 'Chunky Munky'

    flavor = models.CharField(
        max_length=2,
        choices=Flavors.choices
    )


================================================
FILE: code/chapter_06_example_08.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

>>> from orders.models import IceCreamOrder
>>> IceCreamOrder.objects.filter(flavor=IceCreamOrder.Flavors.CHOCOLATE)
[<icecreamorder: 35>, <icecreamorder: 42>, <icecreamorder: 49>]


================================================
FILE: code/chapter_06_example_09.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.db import models
from django.utils import timezone

class PublishedManager(models.Manager):

    def published(self, **kwargs):
        return self.filter(pub_date__lte=timezone.now(), **kwargs)

class FlavorReview(models.Model):
    review = models.CharField(max_length=255)
    pub_date = models.DateTimeField()

    # add our custom model manager
    objects = PublishedManager()


================================================
FILE: code/chapter_06_example_10.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

>>> from reviews.models import FlavorReview
>>> FlavorReview.objects.count()
35
>>> FlavorReview.objects.published().count()
31


================================================
FILE: code/chapter_06_example_11.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

>>> from reviews.models import FlavorReview
>>> FlavorReview.objects.filter().count()
35
>>> FlavorReview.published.filter().count()
31


================================================
FILE: code/chapter_07_example_01.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.core.exceptions import ObjectDoesNotExist

from flavors.models import Flavor
from store.exceptions import OutOfStock

def list_flavor_line_item(sku):
    try:
        return Flavor.objects.get(sku=sku, quantity__gt=0)
    except Flavor.DoesNotExist:
        msg = 'We are out of {0}'.format(sku)
        raise OutOfStock(msg)

def list_any_line_item(model, sku):
    try:
        return model.objects.get(sku=sku, quantity__gt=0)
    except ObjectDoesNotExist:
        msg = 'We are out of {0}'.format(sku)
        raise OutOfStock(msg)


================================================
FILE: code/chapter_07_example_02.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from flavors.models import Flavor
from store.exceptions import OutOfStock, CorruptedDatabase

def list_flavor_line_item(sku):
    try:
        return Flavor.objects.get(sku=sku, quantity__gt=0)
    except Flavor.DoesNotExist:
        msg = 'We are out of {}'.format(sku)
        raise OutOfStock(msg)
    except Flavor.MultipleObjectsReturned:
        msg = 'Multiple items have SKU {}. Please fix!'.format(sku)
        raise CorruptedDatabase(msg)


================================================
FILE: code/chapter_07_example_03.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Don't do this!
from django.db.models import Q

from promos.models import Promo

def fun_function(name=None):
    """Find working ice cream promo"""
    # Too much query chaining makes code go off the screen or page. Not good.
    return Promo.objects.active().filter(Q(name__startswith=name)|Q(description__icontains=name)).exclude(status='melted')


================================================
FILE: code/chapter_07_example_04.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Do this!
from django.db.models import Q

from promos.models import Promo

def fun_function(name=None):
    """Find working ice cream promo"""
    results = Promo.objects.active()
    results = results.filter(
                Q(name__startswith=name) |
                Q(description__icontains=name)
            )
    results = results.exclude(status='melted')
    results = results.select_related('flavors')
    return results


================================================
FILE: code/chapter_07_example_05.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Do this!
from django.db.models import Q

from promos.models import Promo

def fun_function(name=None):
  """Find working ice cream promo"""
  qs = (Promo
          .objects
          .active()
          .filter(
              Q(name__startswith=name) |
              Q(description__icontains=name)
          )
          .exclude(status='melted')
          .select_related('flavors')
      )
    return qs


================================================
FILE: code/chapter_07_example_06.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

def fun_function(name=None):
    """Find working ice cream promo"""
    qs = (
        Promo
        .objects
        .active()
        # .filter(
        #     Q(name__startswith=name) |
        #     Q(description__icontains=name)
        # )
        # .exclude(status='melted')
        # .select_related('flavors')
    )
    breakpoint()
    return qs


================================================
FILE: code/chapter_07_example_07.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Don't do this!
from models.customers import Customer

customers = []
for customer in Customer.objects.iterator():
    if customer.scoops_ordered > customer.store_visits:
        customers.append(customer)


================================================
FILE: code/chapter_07_example_08.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.db.models import F

from models.customers import Customer

customers = Customer.objects.filter(scoops_ordered__gt=F('store_visits'))


================================================
FILE: code/chapter_07_example_09.sql
================================================
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.

********************

SELECT * from customers_customer where scoops_ordered > store_visits


================================================
FILE: code/chapter_07_example_10.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# settings/base.py

DATABASES = {
    'default': {
        # ...
        'ATOMIC_REQUESTS': True,
    },
}


================================================
FILE: code/chapter_07_example_11.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# flavors/views.py

from django.db import transaction
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.utils import timezone

from .models import Flavor

@transaction.non_atomic_requests
def posting_flavor_status(request, pk, status):
    flavor = get_object_or_404(Flavor, pk=pk)

    # This will execute in autocommit mode (Django's default).
    flavor.latest_status_change_attempt = timezone.now()
    flavor.save()

    with transaction.atomic():
        # This code executes inside a transaction.
        flavor.status = status
        flavor.latest_status_change_success = timezone.now()
        flavor.save()
        return HttpResponse('Hooray')

    # If the transaction fails, return the appropriate status
    return HttpResponse('Sadness', status_code=400)


================================================
FILE: code/chapter_08_example_01.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Don't do this!
from django.urls import path
from django.views.generic import DetailView

from tastings.models import Tasting

urlpatterns = [
    path('<int:pk>',
        DetailView.as_view(
            model=Tasting,
            template_name='tastings/detail.html'),
        name='detail'),
    path('<int:pk>/results/',
        DetailView.as_view(
            model=Tasting,
            template_name='tastings/results.html'),
        name='results'),
]


================================================
FILE: code/chapter_08_example_02.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.urls import reverse
from django.views.generic import ListView, DetailView, UpdateView

from .models import Tasting

class TasteListView(ListView):
    model = Tasting

class TasteDetailView(DetailView):
    model = Tasting

class TasteResultsView(TasteDetailView):
    template_name = 'tastings/results.html'

class TasteUpdateView(UpdateView):
    model = Tasting

    def get_success_url(self):
        return reverse('tastings:detail',
            kwargs={'pk': self.object.pk})


================================================
FILE: code/chapter_08_example_03.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.urls import path

from . import views

urlpatterns = [
    path(
        route='',
        view=views.TasteListView.as_view(),
        name='list'
    ),
    path(
        route='<int:pk>/',
        view=views.TasteDetailView.as_view(),
        name='detail'
    ),
    path(
        route='<int:pk>/results/',
        view=views.TasteResultsView.as_view(),
        name='results'
    ),
    path(
        route='<int:pk>/update/',
        view=views.TasteUpdateView.as_view(),
        name='update'
    )
]


================================================
FILE: code/chapter_08_example_04.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

urlpatterns += [
    path('tastings/', include('tastings.urls', namespace='tastings')),
]


================================================
FILE: code/chapter_08_example_05.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# tastings/views.py snippet
class TasteUpdateView(UpdateView):
    model = Tasting

    def get_success_url(self):
        return reverse('tastings:detail',
            kwargs={'pk': self.object.pk})


================================================
FILE: code/chapter_08_example_06.html
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

{% extends 'base.html' %}

{% block title %}Tastings{% endblock title %}

{% block content %}
<ul>
  {% for taste in tastings %}
    <li>
      <a href="{% url 'tastings:detail' taste.pk %}">{{ taste.title }}</a>
      <small>
        (<a href="{% url 'tastings:update' taste.pk %}">update</a>)
      </small>
    </li>
  {% endfor %}
</ul>
{% endblock content %}


================================================
FILE: code/chapter_08_example_07.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# urls.py at root of project
urlpatterns += [
    path('contact/', include('contactmonger.urls',
                                        namespace='contactmonger')),
    path('report-problem/', include('contactapp.urls',
                                            namespace='contactapp')),
]


================================================
FILE: code/chapter_08_example_08.html
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

{% extends "base.html" %}
{% block title %}Contact{% endblock title %}
{% block content %}
<p>
  <a href="{% url 'contactmonger:create' %}">Contact Us</a>
</p>
<p>
  <a href="{% url 'contactapp:report' %}">Report a Problem</a>
</p>
{% endblock content %}


================================================
FILE: code/chapter_08_example_09.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Django FBV as a function
HttpResponse = view(HttpRequest)

# Deciphered into basic math (remember functions from algebra?)
y = f(x)

# ... and then translated into a CBV example
HttpResponse = View.as_view()(HttpRequest)


================================================
FILE: code/chapter_08_example_10.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.http import HttpResponse
from django.views.generic import View

# The simplest FBV
def simplest_view(request):
    # Business logic goes here
    return HttpResponse('FBV')

# The simplest CBV
class SimplestView(View):
    def get(self, request, *args, **kwargs):
        # Business logic goes here
        return HttpResponse('CBV')


================================================
FILE: code/chapter_08_example_11.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Don't do this!
def ice_cream_store_display(request, store_id):
    store = get_object_or_404(Store, id=store_id)
    date = timezone.now()
    return render(request, 'melted_ice_cream_report.html', locals())


================================================
FILE: code/chapter_08_example_12.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# Don't do this!
def ice_cream_store_display(request, store_id):
    store = get_object_or_404(Store, id=store_id)
    now = timezone.now()
    return render(request, 'melted_ice_cream_report.html', locals())


================================================
FILE: code/chapter_08_example_13.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

def ice_cream_store_display(request, store_id):
    return render(
        request,
        'melted_ice_cream_report.html',
        {
            'store': get_object_or_404(Store, id=store_id),
            'now': timezone.now()
        }
    )


================================================
FILE: code/chapter_09_example_01.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.core.exceptions import PermissionDenied
from django.http import HttpRequest

def check_sprinkle_rights(request: HttpRequest) -> HttpRequest:
    if request.user.can_sprinkle or request.user.is_staff:
        return request

    # Return a HTTP 403 back to the user
    raise PermissionDenied


================================================
FILE: code/chapter_09_example_02.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

from django.core.exceptions import PermissionDenied
from django.http import HttpRequest, HttpResponse

def check_sprinkles(request: HttpRequest) -> HttpRequest:
    if request.user.can_sprinkle or request.user.is_staff:
        # By adding this value here it means our display templates
        #   can be more generic. We don't need to have
        #   {% if request.user.can_sprinkle or request.user.is_staff %}
        #   instead just using
        #   {% if request.can_sprinkle %}
        request.can_sprinkle = True
        return request

    # Return a HTTP 403 back to the user
    raise PermissionDenied


================================================
FILE: code/chapter_09_example_03.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
purposes of improving book formatting. Example code is provided "as is", and
is not intended to be, and should not be considered or labeled as "tutorial
code".

Permissions
============
In general, you may use the code we've provided with this book in your
programs and documentation. You do not need to contact us for permission
unless you're reproducing a significant portion of the code or using it in
commercial distributions. Examples:
* Writing a program that uses several chunks of code from this course does
    not require permission.
* Selling or distributing a digital package from material taken from this
    book does require permission.
* Answering a question by citing this book and quoting example code does not
    require permission.
* Incorporating a significant amount of example code from this book into your
    product's documentation does require permission.
Attributions usually include the title, author, publisher and an ISBN. For
example, "Two Scoops of Django: Best Practices for Django 3.x, by Daniel and
Audrey Roy Greenfeld. Copyright 2020 Feldroy.com."

If you feel your use of code examples falls outside fair use of the permission
given here, please contact us at hi@feldroy.com.
"""

# sprinkles/views.py
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from django.http import HttpRequest, HttpResponse

from .models import Sprinkle
from .utils import check_sprinkles

def sprinkle_list(request: HttpRequest) -> HttpResponse:
    """Standard list view"""

    request = check_sprinkles(request)

    return render(request,
        "sprinkles/sprinkle_list.html",
        {"sprinkles": Sprinkle.objects.all()})

def sprinkle_detail(request: HttpRequest, pk: int) -> HttpResponse:
    """Standard detail view"""

    request = check_sprinkles(request)

    sprinkle = get_object_or_404(Sprinkle, pk=pk)

    return render(request, "sprinkles/sprinkle_detail.html",
        {"sprinkle": sprinkle})

def sprinkle_preview(request: HttpRequest) -> HttpResponse:
    """Preview of new sprinkle, but without the
            check_sprinkles function being used.
    """
    sprinkle = Sprinkle.objects.all()
    return render(request,
        "sprinkles/sprinkle_preview.html",
        {"sprinkle": sprinkle})


================================================
FILE: code/chapter_09_example_04.py
================================================
"""
Using This Code Example
=========================
The code examples provided are provided by Daniel and Audrey Roy Greenfeld of
feldroy.com to help you reference Two Scoops of Django: Best Practices
for Django 3.x. Code samples follow PEP-0008, with exceptions made for the
pu
Download .txt
gitextract_y76tine9/

├── .github/
│   └── FUNDING.yml
├── ISSUE_TEMPLATE
├── README.md
├── changelog.md
└── code/
    ├── chapter_00_example_01.py
    ├── chapter_00_example_02.py
    ├── chapter_01_example_01.py
    ├── chapter_01_example_02.py
    ├── chapter_01_example_03.py
    ├── chapter_01_example_04.py
    ├── chapter_01_example_05.py
    ├── chapter_01_example_06.py
    ├── chapter_01_example_07.py
    ├── chapter_01_example_08.py
    ├── chapter_02_example_01.txt
    ├── chapter_02_example_02.txt
    ├── chapter_03_example_01.txt
    ├── chapter_03_example_02.txt
    ├── chapter_03_example_03.txt
    ├── chapter_03_example_04.txt
    ├── chapter_03_example_05.txt
    ├── chapter_03_example_06.txt
    ├── chapter_03_example_07.txt
    ├── chapter_03_example_08.txt
    ├── chapter_03_example_09.txt
    ├── chapter_03_example_10.txt
    ├── chapter_04_example_01.txt
    ├── chapter_04_example_02.txt
    ├── chapter_04_example_03.py
    ├── chapter_04_example_04.txt
    ├── chapter_04_example_05.py
    ├── chapter_05_example_01.txt
    ├── chapter_05_example_02.txt
    ├── chapter_05_example_03.txt
    ├── chapter_05_example_04.py
    ├── chapter_05_example_05.txt
    ├── chapter_05_example_06.py
    ├── chapter_05_example_07.txt
    ├── chapter_05_example_08.txt
    ├── chapter_05_example_09.txt
    ├── chapter_05_example_10.txt
    ├── chapter_05_example_11.txt
    ├── chapter_05_example_12.txt
    ├── chapter_05_example_13.txt
    ├── chapter_05_example_14.py
    ├── chapter_05_example_15.py
    ├── chapter_05_example_16.py
    ├── chapter_05_example_17.py
    ├── chapter_05_example_18.py
    ├── chapter_05_example_19.json
    ├── chapter_05_example_20.py
    ├── chapter_05_example_21.txt
    ├── chapter_05_example_22.txt
    ├── chapter_05_example_23.txt
    ├── chapter_05_example_24.txt
    ├── chapter_05_example_25.txt
    ├── chapter_05_example_26.txt
    ├── chapter_05_example_27.txt
    ├── chapter_05_example_28.py
    ├── chapter_05_example_29.py
    ├── chapter_05_example_30.py
    ├── chapter_06_example_01.py
    ├── chapter_06_example_02.py
    ├── chapter_06_example_03.py
    ├── chapter_06_example_04.py
    ├── chapter_06_example_05.py
    ├── chapter_06_example_06.py
    ├── chapter_06_example_07.py
    ├── chapter_06_example_08.py
    ├── chapter_06_example_09.py
    ├── chapter_06_example_10.py
    ├── chapter_06_example_11.py
    ├── chapter_07_example_01.py
    ├── chapter_07_example_02.py
    ├── chapter_07_example_03.py
    ├── chapter_07_example_04.py
    ├── chapter_07_example_05.py
    ├── chapter_07_example_06.py
    ├── chapter_07_example_07.py
    ├── chapter_07_example_08.py
    ├── chapter_07_example_09.sql
    ├── chapter_07_example_10.py
    ├── chapter_07_example_11.py
    ├── chapter_08_example_01.py
    ├── chapter_08_example_02.py
    ├── chapter_08_example_03.py
    ├── chapter_08_example_04.py
    ├── chapter_08_example_05.py
    ├── chapter_08_example_06.html
    ├── chapter_08_example_07.py
    ├── chapter_08_example_08.html
    ├── chapter_08_example_09.py
    ├── chapter_08_example_10.py
    ├── chapter_08_example_11.py
    ├── chapter_08_example_12.py
    ├── chapter_08_example_13.py
    ├── chapter_09_example_01.py
    ├── chapter_09_example_02.py
    ├── chapter_09_example_03.py
    ├── chapter_09_example_04.py
    ├── chapter_09_example_05.py
    ├── chapter_09_example_06.py
    ├── chapter_09_example_07.py
    ├── chapter_10_example_01.py
    ├── chapter_10_example_02.py
    ├── chapter_10_example_03.py
    ├── chapter_10_example_04.py
    ├── chapter_10_example_05.py
    ├── chapter_10_example_06.html
    ├── chapter_10_example_07.py
    ├── chapter_10_example_08.py
    ├── chapter_10_example_09.py
    ├── chapter_10_example_10.html
    ├── chapter_10_example_11.py
    ├── chapter_10_example_12.html
    ├── chapter_10_example_13.py
    ├── chapter_10_example_14.py
    ├── chapter_11_example_01.py
    ├── chapter_11_example_02.py
    ├── chapter_11_example_03.py
    ├── chapter_12_example_01.py
    ├── chapter_12_example_02.py
    ├── chapter_12_example_03.py
    ├── chapter_12_example_04.py
    ├── chapter_12_example_05.py
    ├── chapter_12_example_06.py
    ├── chapter_12_example_07.py
    ├── chapter_12_example_08.py
    ├── chapter_12_example_09.py
    ├── chapter_12_example_10.py
    ├── chapter_12_example_11.py
    ├── chapter_12_example_12.py
    ├── chapter_12_example_13.py
    ├── chapter_12_example_14.py
    ├── chapter_12_example_15.py
    ├── chapter_12_example_16.py
    ├── chapter_12_example_17.html
    ├── chapter_12_example_18.html
    ├── chapter_13_example_01.py
    ├── chapter_13_example_02.py
    ├── chapter_13_example_03.html
    ├── chapter_13_example_04.py
    ├── chapter_13_example_05.py
    ├── chapter_13_example_06.py
    ├── chapter_13_example_07.py
    ├── chapter_13_example_08.py
    ├── chapter_13_example_09.py
    ├── chapter_13_example_10.py
    ├── chapter_14_example_01.txt
    ├── chapter_14_example_02.txt
    ├── chapter_14_example_03.txt
    ├── chapter_14_example_04.txt
    ├── chapter_14_example_05.py
    ├── chapter_14_example_06.html
    ├── chapter_14_example_07.py
    ├── chapter_14_example_08.html
    ├── chapter_14_example_09.py
    ├── chapter_14_example_10.html
    ├── chapter_14_example_11.html
    ├── chapter_14_example_12.html
    ├── chapter_14_example_13.html
    ├── chapter_14_example_14.html
    ├── chapter_14_example_15.html
    ├── chapter_14_example_16.html
    ├── chapter_14_example_17.html
    ├── chapter_14_example_18.html
    ├── chapter_14_example_19.html
    ├── chapter_14_example_20.html
    ├── chapter_14_example_21.html
    ├── chapter_14_example_22.html
    ├── chapter_14_example_23.html
    ├── chapter_14_example_24.py
    ├── chapter_15_example_01.html
    ├── chapter_15_example_02.py
    ├── chapter_16_example_01.html
    ├── chapter_16_example_02.py
    ├── chapter_16_example_03.html
    ├── chapter_16_example_04.py
    ├── chapter_16_example_05.html
    ├── chapter_16_example_06.py
    ├── chapter_17_example_01.py
    ├── chapter_17_example_02.py
    ├── chapter_17_example_03.py
    ├── chapter_17_example_04.py
    ├── chapter_17_example_05.py
    ├── chapter_17_example_06.txt
    ├── chapter_17_example_07.txt
    ├── chapter_17_example_08.txt
    ├── chapter_17_example_09.txt
    ├── chapter_17_example_10.py
    ├── chapter_17_example_11.py
    ├── chapter_17_example_12.txt
    ├── chapter_17_example_13.txt
    ├── chapter_17_example_14.txt
    ├── chapter_17_example_15.py
    ├── chapter_17_example_16.py
    ├── chapter_18_example_01.txt
    ├── chapter_18_example_02.txt
    ├── chapter_19_example_01.html
    ├── chapter_21_example_01.py
    ├── chapter_21_example_02.py
    ├── chapter_21_example_03.py
    ├── chapter_21_example_04.py
    ├── chapter_22_example_01.py
    ├── chapter_22_example_02.py
    ├── chapter_22_example_03.py
    ├── chapter_22_example_04.py
    ├── chapter_22_example_05.py
    ├── chapter_22_example_06.py
    ├── chapter_22_example_07.py
    ├── chapter_22_example_08.py
    ├── chapter_22_example_09.py
    ├── chapter_22_example_10.py
    ├── chapter_22_example_11.py
    ├── chapter_22_example_12.py
    ├── chapter_23_example_01.txt
    ├── chapter_23_example_02.txt
    ├── chapter_23_example_03.txt
    ├── chapter_23_example_04.txt
    ├── chapter_23_example_05.txt
    ├── chapter_23_example_06.txt
    ├── chapter_23_example_07.txt
    ├── chapter_23_example_08.txt
    ├── chapter_23_example_09.txt
    ├── chapter_23_example_10.txt
    ├── chapter_23_example_11.txt
    ├── chapter_24_example_01.txt
    ├── chapter_24_example_02.py
    ├── chapter_24_example_03.py
    ├── chapter_24_example_04.py
    ├── chapter_24_example_05.py
    ├── chapter_24_example_06.py
    ├── chapter_24_example_07.py
    ├── chapter_24_example_08.txt
    ├── chapter_24_example_09.txt
    ├── chapter_24_example_10.txt
    ├── chapter_24_example_11.py
    ├── chapter_25_example_01.txt
    ├── chapter_25_example_02.txt
    ├── chapter_28_example_01.py
    ├── chapter_28_example_02.txt
    ├── chapter_28_example_03.py
    ├── chapter_28_example_04.py
    ├── chapter_28_example_05.py
    ├── chapter_28_example_06.py
    ├── chapter_28_example_07.py
    ├── chapter_28_example_08.py
    ├── chapter_28_example_09.py
    ├── chapter_28_example_10.py
    ├── chapter_28_example_11.html
    ├── chapter_28_example_12.html
    ├── chapter_29_example_01.py
    ├── chapter_29_example_02.py
    ├── chapter_29_example_03.py
    ├── chapter_29_example_04.py
    ├── chapter_29_example_05.py
    ├── chapter_29_example_06.py
    ├── chapter_30_example_01.py
    ├── chapter_30_example_02.py
    ├── chapter_30_example_03.txt
    ├── chapter_31_example_01.txt
    ├── chapter_31_example_02.py
    ├── chapter_31_example_03.py
    ├── chapter_31_example_04.py
    ├── chapter_31_example_05.py
    ├── chapter_31_example_06.py
    ├── chapter_31_example_07.py
    ├── chapter_31_example_08.py
    ├── chapter_31_example_09.py
    ├── chapter_31_example_10.py
    ├── chapter_31_example_11.py
    ├── chapter_35_example_01.txt
    ├── chapter_35_example_02.py
    ├── chapter_35_example_03.py
    ├── chapter_35_example_04.html
    ├── chapter_35_example_05.py
    ├── chapter_35_example_06.py
    ├── chapter_35_example_07.py
    ├── chapter_35_example_08.py
    ├── chapter_39_example_01.txt
    ├── chapter_39_example_02.txt
    ├── chapter_39_example_03.txt
    ├── chapter_39_example_04.txt
    ├── chapter_39_example_05.txt
    ├── chapter_39_example_06.txt
    ├── chapter_39_example_07.txt
    ├── chapter_39_example_08.txt
    ├── chapter_41_example_01.py
    ├── chapter_41_example_02.py
    ├── chapter_41_example_03.py
    ├── chapter_41_example_04.py
    └── chapter_41_example_05.py
Download .txt
SYMBOL INDEX (266 symbols across 125 files)

FILE: code/chapter_00_example_01.py
  class Scoop (line 33) | class Scoop:
    method __init__ (line 34) | def __init__(self):

FILE: code/chapter_00_example_02.py
  class Scoop (line 33) | class Scoop:
    method __init__ (line 34) | def __init__(self):

FILE: code/chapter_01_example_02.py
  class WaffleConeCreateView (line 43) | class WaffleConeCreateView(FoodMixin, CreateView):

FILE: code/chapter_04_example_03.py
  class UserManager (line 33) | class UserManager(BaseUserManager):
    method create_user (line 35) | def create_user(self, email=None, password=None, avatar_url=None):
  class TicketManager (line 47) | class TicketManager(models.manager):
    method create_ticket (line 49) | def create_ticket(self, user: User):

FILE: code/chapter_04_example_05.py
  function create_user (line 37) | def create_user(email: str, password: str, avatar_url: str) -> User:

FILE: code/chapter_05_example_16.py
  function get_env_variable (line 40) | def get_env_variable(var_name):

FILE: code/chapter_05_example_20.py
  function get_secret (line 44) | def get_secret(setting, secrets=secrets):

FILE: code/chapter_05_example_30.py
  function root (line 36) | def root(*dirs):

FILE: code/chapter_06_example_01.py
  class TimeStampedModel (line 35) | class TimeStampedModel(models.Model):
    class Meta (line 43) | class Meta:

FILE: code/chapter_06_example_02.py
  class Meta (line 33) | class Meta:

FILE: code/chapter_06_example_03.py
  class Flavor (line 38) | class Flavor(TimeStampedModel):

FILE: code/chapter_06_example_04.py
  function add_cones (line 35) | def add_cones(apps, schema_editor):
  class Migration (line 45) | class Migration(migrations.Migration):

FILE: code/chapter_06_example_05.py
  class IceCreamOrder (line 36) | class IceCreamOrder(models.Model):

FILE: code/chapter_06_example_07.py
  class IceCreamOrder (line 35) | class IceCreamOrder(models.Model):
    class Flavors (line 36) | class Flavors(models.TextChoices):

FILE: code/chapter_06_example_09.py
  class PublishedManager (line 36) | class PublishedManager(models.Manager):
    method published (line 38) | def published(self, **kwargs):
  class FlavorReview (line 41) | class FlavorReview(models.Model):

FILE: code/chapter_07_example_01.py
  function list_flavor_line_item (line 38) | def list_flavor_line_item(sku):
  function list_any_line_item (line 45) | def list_any_line_item(model, sku):

FILE: code/chapter_07_example_02.py
  function list_flavor_line_item (line 36) | def list_flavor_line_item(sku):

FILE: code/chapter_07_example_03.py
  function fun_function (line 38) | def fun_function(name=None):

FILE: code/chapter_07_example_04.py
  function fun_function (line 38) | def fun_function(name=None):

FILE: code/chapter_07_example_05.py
  function fun_function (line 38) | def fun_function(name=None):

FILE: code/chapter_07_example_06.py
  function fun_function (line 33) | def fun_function(name=None):

FILE: code/chapter_07_example_11.py
  function posting_flavor_status (line 43) | def posting_flavor_status(request, pk, status):

FILE: code/chapter_08_example_02.py
  class TasteListView (line 38) | class TasteListView(ListView):
  class TasteDetailView (line 41) | class TasteDetailView(DetailView):
  class TasteResultsView (line 44) | class TasteResultsView(TasteDetailView):
  class TasteUpdateView (line 47) | class TasteUpdateView(UpdateView):
    method get_success_url (line 50) | def get_success_url(self):

FILE: code/chapter_08_example_05.py
  class TasteUpdateView (line 34) | class TasteUpdateView(UpdateView):
    method get_success_url (line 37) | def get_success_url(self):

FILE: code/chapter_08_example_10.py
  function simplest_view (line 37) | def simplest_view(request):
  class SimplestView (line 42) | class SimplestView(View):
    method get (line 43) | def get(self, request, *args, **kwargs):

FILE: code/chapter_08_example_11.py
  function ice_cream_store_display (line 34) | def ice_cream_store_display(request, store_id):

FILE: code/chapter_08_example_12.py
  function ice_cream_store_display (line 34) | def ice_cream_store_display(request, store_id):

FILE: code/chapter_08_example_13.py
  function ice_cream_store_display (line 33) | def ice_cream_store_display(request, store_id):

FILE: code/chapter_09_example_01.py
  function check_sprinkle_rights (line 36) | def check_sprinkle_rights(request: HttpRequest) -> HttpRequest:

FILE: code/chapter_09_example_02.py
  function check_sprinkles (line 36) | def check_sprinkles(request: HttpRequest) -> HttpRequest:

FILE: code/chapter_09_example_03.py
  function sprinkle_list (line 41) | def sprinkle_list(request: HttpRequest) -> HttpResponse:
  function sprinkle_detail (line 50) | def sprinkle_detail(request: HttpRequest, pk: int) -> HttpResponse:
  function sprinkle_preview (line 60) | def sprinkle_preview(request: HttpRequest) -> HttpResponse:

FILE: code/chapter_09_example_04.py
  class SprinkleDetail (line 38) | class SprinkleDetail(DetailView):
    method dispatch (line 43) | def dispatch(self, request, *args, **kwargs):

FILE: code/chapter_09_example_05.py
  function decorator (line 35) | def decorator(view_func):

FILE: code/chapter_09_example_06.py
  function check_sprinkles (line 39) | def check_sprinkles(view_func):

FILE: code/chapter_09_example_07.py
  function sprinkle_detail (line 41) | def sprinkle_detail(request: HttpRequest, pk: int) -> HttpResponse:

FILE: code/chapter_10_example_01.py
  class FreshFruitMixin (line 35) | class FreshFruitMixin:
    method get_context_data (line 37) | def get_context_data(self, **kwargs):
  class FruityFlavorView (line 42) | class FruityFlavorView(FreshFruitMixin, TemplateView):

FILE: code/chapter_10_example_02.py
  class FlavorDetailView (line 39) | class FlavorDetailView(LoginRequiredMixin, DetailView):

FILE: code/chapter_10_example_03.py
  class FlavorCreateView (line 38) | class FlavorCreateView(LoginRequiredMixin, CreateView):
    method form_valid (line 42) | def form_valid(self, form):

FILE: code/chapter_10_example_04.py
  class FlavorCreateView (line 38) | class FlavorCreateView(LoginRequiredMixin, CreateView):
    method form_invalid (line 41) | def form_invalid(self, form):

FILE: code/chapter_10_example_05.py
  class FavoriteMixin (line 40) | class FavoriteMixin:
    method likes_and_favorites (line 43) | def likes_and_favorites(self):
  class FlavorUpdateView (line 54) | class FlavorUpdateView(LoginRequiredMixin, FavoriteMixin, UpdateView):
    method form_valid (line 58) | def form_valid(self, form):
  class FlavorDetailView (line 65) | class FlavorDetailView(LoginRequiredMixin, FavoriteMixin, TemplateView):

FILE: code/chapter_10_example_07.py
  class Flavor (line 37) | class Flavor(models.Model):
    class Scoops (line 38) | class Scoops(models.IntegerChoices):
    method get_absolute_url (line 47) | def get_absolute_url(self):

FILE: code/chapter_10_example_08.py
  class FlavorCreateView (line 39) | class FlavorCreateView(LoginRequiredMixin, CreateView):
  class FlavorUpdateView (line 43) | class FlavorUpdateView(LoginRequiredMixin, UpdateView):
  class FlavorDetailView (line 47) | class FlavorDetailView(DetailView):

FILE: code/chapter_10_example_09.py
  class FlavorActionMixin (line 40) | class FlavorActionMixin:
    method success_msg (line 45) | def success_msg(self):
    method form_valid (line 48) | def form_valid(self, form):
  class FlavorCreateView (line 52) | class FlavorCreateView(LoginRequiredMixin, FlavorActionMixin,
  class FlavorUpdateView (line 57) | class FlavorUpdateView(LoginRequiredMixin, FlavorActionMixin,
  class FlavorDetailView (line 62) | class FlavorDetailView(DetailView):

FILE: code/chapter_10_example_11.py
  class FlavorListView (line 37) | class FlavorListView(ListView):
    method get_queryset (line 40) | def get_queryset(self):

FILE: code/chapter_10_example_13.py
  class FlavorView (line 41) | class FlavorView(LoginRequiredMixin, View):
    method get (line 43) | def get(self, request, *args, **kwargs):
    method post (line 51) | def post(self, request, *args, **kwargs):

FILE: code/chapter_10_example_14.py
  class FlavorPDFView (line 41) | class FlavorPDFView(LoginRequiredMixin, View):
    method get (line 43) | def get(self, request, *args, **kwargs):

FILE: code/chapter_11_example_01.py
  class AsyncViewMixin (line 34) | class AsyncViewMixin:
    method __call__ (line 35) | async def __call__(self):

FILE: code/chapter_11_example_02.py
  class FlavorUpdateView (line 43) | class FlavorUpdateView(LoginRequiredMixin, AsyncViewMixin, View):
    method get (line 44) | def get(self, request, *args, **kwargs):
    method post (line 48) | def post(self, request, *args, **kwargs):

FILE: code/chapter_11_example_03.py
  class InvokeMicroserviceView (line 42) | class InvokeMicroserviceView(LoginRequiredMixin, AsyncViewMixin, View):
    method post (line 44) | def post(self, request, *args, **kwargs):

FILE: code/chapter_12_example_01.py
  class FlavorCreateView (line 38) | class FlavorCreateView(LoginRequiredMixin, CreateView):
  class FlavorUpdateView (line 42) | class FlavorUpdateView(LoginRequiredMixin, UpdateView):

FILE: code/chapter_12_example_02.py
  function validate_tasty (line 36) | def validate_tasty(value):

FILE: code/chapter_12_example_03.py
  class TastyTitleAbstractModel (line 38) | class TastyTitleAbstractModel(models.Model):
    class Meta (line 42) | class Meta:

FILE: code/chapter_12_example_04.py
  class Flavor (line 39) | class Flavor(TastyTitleAbstractModel):
    method get_absolute_url (line 43) | def get_absolute_url(self):

FILE: code/chapter_12_example_05.py
  class FlavorForm (line 39) | class FlavorForm(forms.ModelForm):
    method __init__ (line 40) | def __init__(self, *args, **kwargs):
    class Meta (line 45) | class Meta:

FILE: code/chapter_12_example_06.py
  class FlavorActionMixin (line 41) | class FlavorActionMixin:
    method success_msg (line 47) | def success_msg(self):
    method form_valid (line 50) | def form_valid(self, form):
  class FlavorCreateView (line 54) | class FlavorCreateView(LoginRequiredMixin, FlavorActionMixin,
  class FlavorUpdateView (line 60) | class FlavorUpdateView(LoginRequiredMixin, FlavorActionMixin,
  class FlavorDetailView (line 66) | class FlavorDetailView(DetailView):

FILE: code/chapter_12_example_07.py
  class IceCreamOrderForm (line 38) | class IceCreamOrderForm(forms.Form):
    method __init__ (line 46) | def __init__(self, *args, **kwargs):
    method clean_slug (line 59) | def clean_slug(self):

FILE: code/chapter_12_example_08.py
  function clean (line 34) | def clean(self):

FILE: code/chapter_12_example_09.py
  class IceCreamStore (line 37) | class IceCreamStore(models.Model):
    method get_absolute_url (line 43) | def get_absolute_url(self):

FILE: code/chapter_12_example_10.py
  class IceCreamStoreUpdateForm (line 38) | class IceCreamStoreUpdateForm(forms.ModelForm):
    class Meta (line 44) | class Meta:

FILE: code/chapter_12_example_11.py
  class IceCreamStoreUpdateForm (line 39) | class IceCreamStoreUpdateForm(forms.ModelForm):
    class Meta (line 41) | class Meta:
    method __init__ (line 45) | def __init__(self, *args, **kwargs):

FILE: code/chapter_12_example_12.py
  class IceCreamStoreCreateForm (line 38) | class IceCreamStoreCreateForm(forms.ModelForm):
    class Meta (line 40) | class Meta:
  class IceCreamStoreUpdateForm (line 44) | class IceCreamStoreUpdateForm(IceCreamStoreCreateForm):
    method __init__ (line 46) | def __init__(self, *args, **kwargs):
    class Meta (line 51) | class Meta(IceCreamStoreCreateForm.Meta):

FILE: code/chapter_12_example_13.py
  class IceCreamCreateView (line 39) | class IceCreamCreateView(CreateView):
  class IceCreamUpdateView (line 43) | class IceCreamUpdateView(UpdateView):

FILE: code/chapter_12_example_14.py
  class TitleSearchMixin (line 34) | class TitleSearchMixin:
    method get_queryset (line 36) | def get_queryset(self):

FILE: code/chapter_12_example_15.py
  class FlavorListView (line 39) | class FlavorListView(TitleSearchMixin, ListView):

FILE: code/chapter_12_example_16.py
  class IceCreamStoreListView (line 39) | class IceCreamStoreListView(TitleSearchMixin, ListView):

FILE: code/chapter_13_example_01.py
  function add_csv_purchases (line 39) | def add_csv_purchases(rows):

FILE: code/chapter_13_example_02.py
  class PurchaseForm (line 41) | class PurchaseForm(forms.ModelForm):
    class Meta (line 43) | class Meta:
    method clean_seller (line 47) | def clean_seller(self):
  function add_csv_purchases (line 59) | def add_csv_purchases(rows):

FILE: code/chapter_13_example_04.py
  class TasterForm (line 37) | class TasterForm(forms.ModelForm):
    class Meta (line 39) | class Meta:
    method __init__ (line 43) | def __init__(self, *args, **kwargs):

FILE: code/chapter_13_example_05.py
  class TasterUpdateView (line 39) | class TasterUpdateView(LoginRequiredMixin, UpdateView):
    method get_form_kwargs (line 44) | def get_form_kwargs(self):

FILE: code/chapter_13_example_06.py
  class ModelFormFailureHistory (line 36) | class ModelFormFailureHistory(models.Model):

FILE: code/chapter_13_example_07.py
  class FlavorActionMixin (line 41) | class FlavorActionMixin:
    method success_msg (line 44) | def success_msg(self):
    method form_valid (line 47) | def form_valid(self, form):
    method form_invalid (line 51) | def form_invalid(self, form):

FILE: code/chapter_13_example_08.py
  class IceCreamReviewForm (line 35) | class IceCreamReviewForm(forms.Form):
    method clean (line 39) | def clean(self):

FILE: code/chapter_13_example_10.py
  class IceCreamFlavorInput (line 36) | class IceCreamFlavorInput(TextInput):
    method get_context (line 39) | def get_context(self, name, value, attrs):

FILE: code/chapter_14_example_05.py
  class Voucher (line 39) | class Voucher(models.Model):

FILE: code/chapter_14_example_07.py
  class VoucherManager (line 39) | class VoucherManager(models.Manager):
    method age_breakdown (line 40) | def age_breakdown(self):

FILE: code/chapter_14_example_09.py
  class GreenfeldRoyView (line 38) | class GreenfeldRoyView(TemplateView):
    method get_context_data (line 41) | def get_context_data(self, **kwargs):

FILE: code/chapter_16_example_02.py
  function environment (line 40) | def environment(**options):

FILE: code/chapter_16_example_04.py
  class DjFilterMixin (line 36) | class DjFilterMixin:

FILE: code/chapter_16_example_06.py
  function environment (line 38) | def environment(**options):

FILE: code/chapter_17_example_02.py
  class Flavor (line 39) | class Flavor(models.Model):
    method get_absolute_url (line 48) | def get_absolute_url(self):

FILE: code/chapter_17_example_03.py
  class FlavorSerializer (line 38) | class FlavorSerializer(serializers.ModelSerializer):
    class Meta (line 39) | class Meta:

FILE: code/chapter_17_example_04.py
  class FlavorListCreateAPIView (line 43) | class FlavorListCreateAPIView(ListCreateAPIView):
  class FlavorRetrieveUpdateDestroyAPIView (line 49) | class FlavorRetrieveUpdateDestroyAPIView(RetrieveUpdateDestroyAPIView):

FILE: code/chapter_17_example_11.py
  class PourSyrupOnSundaeView (line 42) | class PourSyrupOnSundaeView(APIView):
    method post (line 45) | def post(self, request, *args, **kwargs):

FILE: code/chapter_17_example_15.py
  function apiv1_gone (line 50) | def apiv1_gone(request):

FILE: code/chapter_17_example_16.py
  class FlavorApiView (line 33) | class FlavorApiView(LoginRequiredMixin,View):
    method post (line 34) | def post(self, request, *args, **kwargs):
    method get (line 38) | def get(self, request, *args, **kwargs):
    method put (line 42) | def put(self, request, *args, **kwargs):
    method delete (line 46) | def delete(self, request, *args, **kwargs):

FILE: code/chapter_21_example_01.py
  class IceCreamBar (line 35) | class IceCreamBar(models.Model):
    method __str__ (line 41) | def __str__(self):

FILE: code/chapter_21_example_03.py
  class IceCreamBarModelAdmin (line 38) | class IceCreamBarModelAdmin(admin.ModelAdmin):

FILE: code/chapter_21_example_04.py
  class IceCreamBarModelAdmin (line 41) | class IceCreamBarModelAdmin(admin.ModelAdmin):
    method show_url (line 45) | def show_url(self, instance):

FILE: code/chapter_22_example_02.py
  class IceCreamStore (line 36) | class IceCreamStore(models.Model):

FILE: code/chapter_22_example_03.py
  class IceCreamStore (line 37) | class IceCreamStore(models.Model):

FILE: code/chapter_22_example_04.py
  class KarmaUser (line 37) | class KarmaUser(AbstractUser):

FILE: code/chapter_22_example_06.py
  class EaterProfile (line 40) | class EaterProfile(models.Model):
  class ScooperProfile (line 48) | class ScooperProfile(models.Model):
  class InventorProfile (line 53) | class InventorProfile(models.Model):

FILE: code/chapter_22_example_07.py
  class User (line 33) | class User(AbstractUser):
    class Types (line 34) | class Types(models.TextChoices):

FILE: code/chapter_22_example_08.py
  class User (line 33) | class User(AbstractUser):
    class Types (line 34) | class Types(models.TextChoices):
    method save (line 51) | def save(self, *args, **kwargs):

FILE: code/chapter_22_example_09.py
  class InventorManager (line 33) | class InventorManager(BaseUserManager):
    method get_queryset (line 34) | def get_queryset(self, *args, **kwargs):
  class Inventor (line 38) | class Inventor(User):
    class Meta (line 47) | class Meta:
    method invent (line 51) | def invent(self):

FILE: code/chapter_22_example_12.py
  class Inventor (line 33) | class Inventor(User):
    class Meta (line 37) | class Meta:
    method extra (line 41) | def extra(self):
  class Scooper (line 44) | class Scooper(User):
    class Meta (line 48) | class Meta:
    method extra (line 52) | def extra(self):
  class Eater (line 55) | class Eater(User):
    class Meta (line 59) | class Meta:
    method extra (line 63) | def extra(self):

FILE: code/chapter_24_example_02.py
  class FlavorAPITests (line 41) | class FlavorAPITests(TestCase):
    method setUp (line 43) | def setUp(self):
    method test_list (line 46) | def test_list(self):

FILE: code/chapter_24_example_03.py
  class DjangoRestFrameworkTests (line 41) | class DjangoRestFrameworkTests(TestCase):
    method setUp (line 43) | def setUp(self):
    method test_list (line 51) | def test_list(self):
    method test_detail (line 58) | def test_detail(self):
    method test_create (line 65) | def test_create(self):
    method test_delete (line 75) | def test_delete(self):

FILE: code/chapter_24_example_04.py
  function add_middleware_to_request (line 39) | def add_middleware_to_request(request, middleware_class):
  function add_middleware_to_response (line 44) | def add_middleware_to_response(request, middleware_class):
  class SavoryIceCreamTest (line 49) | class SavoryIceCreamTest(TestCase):
    method setUp (line 50) | def setUp(self):
    method test_cheese_flavors (line 54) | def test_cheese_flavors(self):

FILE: code/chapter_24_example_05.py
  class TestIceCreamSorting (line 40) | class TestIceCreamSorting(TestCase):
    method test_flavor_sort (line 44) | def test_flavor_sort(self, get_flavors):

FILE: code/chapter_24_example_06.py
  function test_flavor_sort_failure (line 34) | def test_flavor_sort_failure(self, get_flavors):

FILE: code/chapter_24_example_07.py
  function test_request_failure (line 34) | def test_request_failure(self, get):
  function test_request_failure_ssl (line 42) | def test_request_failure_ssl(self, get):

FILE: code/chapter_24_example_11.py
  function test_good_choice (line 38) | def test_good_choice():
  function test_bad_cone_choice (line 41) | def test_bad_cone_choice():

FILE: code/chapter_28_example_03.py
  class SpecialForm (line 35) | class SpecialForm(forms.Form):

FILE: code/chapter_28_example_04.py
  class SecretInPublicForm (line 35) | class SecretInPublicForm(forms.Form):

FILE: code/chapter_28_example_05.py
  class Store (line 37) | class Store(models.Model):

FILE: code/chapter_28_example_06.py
  class StoreForm (line 38) | class StoreForm(forms.ModelForm):
    class Meta (line 40) | class Meta:

FILE: code/chapter_28_example_07.py
  class StoreForm (line 37) | class StoreForm(forms.ModelForm):
    class Meta (line 39) | class Meta:

FILE: code/chapter_28_example_08.py
  class Store (line 37) | class Store(models.Model):

FILE: code/chapter_28_example_09.py
  class IceCreamPayment (line 36) | class IceCreamPayment(models.Model):
    method __str__ (line 42) | def __str__(self):

FILE: code/chapter_29_example_03.py
  class PintView (line 37) | class PintView(TemplateView):
    method get_context_data (line 39) | def get_context_data(self, *args, **kwargs):

FILE: code/chapter_29_example_04.py
  class PintView (line 41) | class PintView(TemplateView):
    method get_context_data (line 43) | def get_context_data(self, *args, **kwargs):

FILE: code/chapter_29_example_05.py
  function get_additional_data (line 38) | def get_additional_data():

FILE: code/chapter_30_example_01.py
  class EventManager (line 36) | class EventManager(models.Manager):
    method create_event (line 38) | def create_event(self, title, start, end, creator):

FILE: code/chapter_30_example_02.py
  class Event (line 44) | class Event(TimeStampedModel):
    class Status (line 46) | class Status(models.IntegerChoices):
    method notify_admins (line 61) | def notify_admins(self):

FILE: code/chapter_31_example_05.py
  class BorkedObject (line 36) | class BorkedObject:
  function generic_load_tool (line 39) | def generic_load_tool(model, pk):

FILE: code/chapter_31_example_06.py
  function get_object_or_403 (line 38) | def get_object_or_403(model, **kwargs):

FILE: code/chapter_31_example_07.py
  function finance_data_adjudication (line 35) | def finance_data_adjudication(store, sales, issues):

FILE: code/chapter_35_example_05.py
  function upload_file (line 41) | def upload_file(request, pk):

FILE: code/chapter_35_example_06.py
  class UploadFile (line 40) | class UploadFile(View):
    method get_object (line 42) | def get_object(self):
    method post (line 45) | def post(self, request, *args, **kwargs):
    method get (line 53) | def get(self, request, *args, **kwargs):

FILE: code/chapter_35_example_07.py
  class UserBasedExceptionMiddleware (line 38) | class UserBasedExceptionMiddleware:
    method process_exception (line 39) | def process_exception(self, request, exception):

FILE: code/chapter_41_example_02.py
  class FlavorActionMixin (line 36) | class FlavorActionMixin:
    method action (line 39) | def action(self):
    method form_valid (line 43) | def form_valid(self, form):

FILE: code/chapter_41_example_03.py
  function form_valid (line 38) | def form_valid(self, form):

FILE: code/chapter_41_example_04.py
  class FlavorActionMixin (line 36) | class FlavorActionMixin:
    method success_msg (line 39) | def success_msg(self):
  class FlavorCreateView (line 42) | class FlavorCreateView(LoginRequiredMixin, FlavorActionMixin,

FILE: code/chapter_41_example_05.py
  class FlavorActionMixin (line 35) | class FlavorActionMixin:
    method success_msg (line 38) | def success_msg(self):
  class FlavorCreateView (line 41) | class FlavorCreateView(LoginRequiredMixin, FlavorActionMixin,
Condensed preview — 292 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (580K chars).
[
  {
    "path": ".github/FUNDING.yml",
    "chars": 610,
    "preview": "# These are supported funding model platforms\n\ngithub: [pydanny]\npatreon: feldroy\nopen_collective: # Replace with a sing"
  },
  {
    "path": "ISSUE_TEMPLATE",
    "chars": 1210,
    "preview": "## Greetings! \n\nHello! As a reader, you're encouraged to submit bug reports to us for errors that you find. In turn we w"
  },
  {
    "path": "README.md",
    "chars": 1410,
    "preview": "# Two Scoops of Django 3.x\nThe issue tracker, changelog, and code repository for Two Scoops of Django 3.x\n\nTracking thou"
  },
  {
    "path": "changelog.md",
    "chars": 16983,
    "preview": "# Two Scoops of Django Changelog\n\nThis lists many, but not all the changes between TSD 1.11 and TSD 3.x.\n\n# Updates 2023"
  },
  {
    "path": "code/chapter_00_example_01.py",
    "chars": 1566,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_00_example_02.py",
    "chars": 1567,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_01.py",
    "chars": 1821,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_02.py",
    "chars": 1851,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_03.py",
    "chars": 1553,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_04.py",
    "chars": 1588,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_05.py",
    "chars": 1604,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_06.py",
    "chars": 1608,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_07.py",
    "chars": 1602,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_01_example_08.py",
    "chars": 1611,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_02_example_01.txt",
    "chars": 1560,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_02_example_02.txt",
    "chars": 1532,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_01.txt",
    "chars": 1585,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_02.txt",
    "chars": 1793,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_03.txt",
    "chars": 1585,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_04.txt",
    "chars": 1909,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_05.txt",
    "chars": 1574,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_06.txt",
    "chars": 1575,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_07.txt",
    "chars": 1547,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_08.txt",
    "chars": 1526,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_09.txt",
    "chars": 1545,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_03_example_10.txt",
    "chars": 1969,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_04_example_01.txt",
    "chars": 1692,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_04_example_02.txt",
    "chars": 1793,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_04_example_03.py",
    "chars": 2155,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_04_example_04.txt",
    "chars": 1695,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_04_example_05.py",
    "chars": 1934,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_01.txt",
    "chars": 1609,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_02.txt",
    "chars": 1571,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_03.txt",
    "chars": 1573,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_04.py",
    "chars": 1787,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_05.txt",
    "chars": 1573,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_06.py",
    "chars": 1594,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_07.txt",
    "chars": 1651,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_08.txt",
    "chars": 1616,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_09.txt",
    "chars": 1555,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_10.txt",
    "chars": 1762,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_11.txt",
    "chars": 1760,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_12.txt",
    "chars": 1560,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_13.txt",
    "chars": 1650,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_14.py",
    "chars": 1568,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_15.py",
    "chars": 1589,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_16.py",
    "chars": 1988,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_17.py",
    "chars": 1553,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_18.py",
    "chars": 1590,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_19.json",
    "chars": 1635,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_20.py",
    "chars": 2127,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_21.txt",
    "chars": 1589,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_22.txt",
    "chars": 1578,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_23.txt",
    "chars": 1608,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_24.txt",
    "chars": 1582,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_25.txt",
    "chars": 1567,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_26.txt",
    "chars": 1551,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_27.txt",
    "chars": 1556,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_05_example_28.py",
    "chars": 2204,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_29.py",
    "chars": 1867,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_05_example_30.py",
    "chars": 1938,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_01.py",
    "chars": 1832,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_02.py",
    "chars": 1531,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_03.py",
    "chars": 1668,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_04.py",
    "chars": 2608,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_05.py",
    "chars": 1985,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_06.py",
    "chars": 1679,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_07.py",
    "chars": 1851,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_08.py",
    "chars": 1680,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_09.py",
    "chars": 1894,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_10.py",
    "chars": 1627,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_06_example_11.py",
    "chars": 1635,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_01.py",
    "chars": 2048,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_02.py",
    "chars": 1948,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_03.py",
    "chars": 1850,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_04.py",
    "chars": 1928,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_05.py",
    "chars": 1906,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_06.py",
    "chars": 1854,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_07.py",
    "chars": 1706,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_08.py",
    "chars": 1644,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_09.sql",
    "chars": 1582,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_07_example_10.py",
    "chars": 1606,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_07_example_11.py",
    "chars": 2316,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_01.py",
    "chars": 1958,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_02.py",
    "chars": 1993,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_03.py",
    "chars": 2019,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_04.py",
    "chars": 1589,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_05.py",
    "chars": 1699,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_06.html",
    "chars": 1863,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_07.py",
    "chars": 1792,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_08.html",
    "chars": 1754,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_09.py",
    "chars": 1722,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_10.py",
    "chars": 1845,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_11.py",
    "chars": 1709,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_12.py",
    "chars": 1708,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_08_example_13.py",
    "chars": 1743,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_01.py",
    "chars": 1803,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_02.py",
    "chars": 2114,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_03.py",
    "chars": 2551,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_04.py",
    "chars": 1848,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_05.py",
    "chars": 1858,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_06.py",
    "chars": 2070,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_09_example_07.py",
    "chars": 1942,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_01.py",
    "chars": 1827,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_02.py",
    "chars": 1724,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_03.py",
    "chars": 1860,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_04.py",
    "chars": 1813,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_05.py",
    "chars": 2546,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_06.html",
    "chars": 1752,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_07.py",
    "chars": 1981,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_08.py",
    "chars": 1982,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_09.py",
    "chars": 2351,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_10.html",
    "chars": 1801,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_11.py",
    "chars": 1993,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_12.html",
    "chars": 1767,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_13.py",
    "chars": 2392,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_10_example_14.py",
    "chars": 2162,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_11_example_01.py",
    "chars": 1608,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_11_example_02.py",
    "chars": 2333,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_11_example_03.py",
    "chars": 2446,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_01.py",
    "chars": 1895,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_02.py",
    "chars": 1807,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_03.py",
    "chars": 1747,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_04.py",
    "chars": 1855,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_05.py",
    "chars": 1933,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_06.py",
    "chars": 2500,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_07.py",
    "chars": 2711,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_08.py",
    "chars": 2030,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_09.py",
    "chars": 1905,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_10.py",
    "chars": 1898,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_11.py",
    "chars": 2049,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_12.py",
    "chars": 2120,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_13.py",
    "chars": 1885,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_14.py",
    "chars": 1927,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_15.py",
    "chars": 1705,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_16.py",
    "chars": 1709,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_17.html",
    "chars": 1668,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_12_example_18.html",
    "chars": 1670,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_01.py",
    "chars": 1947,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_02.py",
    "chars": 2692,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_03.html",
    "chars": 1552,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_04.py",
    "chars": 1853,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_05.py",
    "chars": 2099,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_06.py",
    "chars": 1662,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_07.py",
    "chars": 2410,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_08.py",
    "chars": 2079,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_09.py",
    "chars": 1629,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_13_example_10.py",
    "chars": 1963,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_01.txt",
    "chars": 1638,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_14_example_02.txt",
    "chars": 1675,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_14_example_03.txt",
    "chars": 1685,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_14_example_04.txt",
    "chars": 1750,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_14_example_05.py",
    "chars": 1971,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_06.html",
    "chars": 1878,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_07.py",
    "chars": 2181,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_08.html",
    "chars": 1980,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_09.py",
    "chars": 1980,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_10.html",
    "chars": 1738,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_11.html",
    "chars": 1876,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_12.html",
    "chars": 1816,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_13.html",
    "chars": 1895,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_14.html",
    "chars": 1938,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_15.html",
    "chars": 1917,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_16.html",
    "chars": 1892,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_17.html",
    "chars": 1854,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_18.html",
    "chars": 1714,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_19.html",
    "chars": 1794,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_20.html",
    "chars": 1715,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_21.html",
    "chars": 1814,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_22.html",
    "chars": 1520,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_23.html",
    "chars": 1535,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_14_example_24.py",
    "chars": 1739,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_15_example_01.html",
    "chars": 1550,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_15_example_02.py",
    "chars": 1745,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_16_example_01.html",
    "chars": 1611,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_16_example_02.py",
    "chars": 1895,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_16_example_03.html",
    "chars": 1809,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_16_example_04.py",
    "chars": 1605,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_16_example_05.html",
    "chars": 1916,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_16_example_06.py",
    "chars": 2113,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_01.py",
    "chars": 1613,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_02.py",
    "chars": 2052,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_03.py",
    "chars": 1752,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_04.py",
    "chars": 2206,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_05.py",
    "chars": 1912,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_06.txt",
    "chars": 1545,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_07.txt",
    "chars": 1722,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_08.txt",
    "chars": 1684,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_09.txt",
    "chars": 1635,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_10.py",
    "chars": 2435,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_11.py",
    "chars": 2812,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_12.txt",
    "chars": 1649,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_13.txt",
    "chars": 1631,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_14.txt",
    "chars": 1715,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_17_example_15.py",
    "chars": 2011,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_17_example_16.py",
    "chars": 1964,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_18_example_01.txt",
    "chars": 1666,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_18_example_02.txt",
    "chars": 1764,
    "preview": "Using This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy Green"
  },
  {
    "path": "code/chapter_19_example_01.html",
    "chars": 1675,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  },
  {
    "path": "code/chapter_21_example_01.py",
    "chars": 1797,
    "preview": "\"\"\"\nUsing This Code Example\n=========================\nThe code examples provided are provided by Daniel and Audrey Roy G"
  }
]

// ... and 92 more files (download for full content)

About this extraction

This page contains the full source code of the feldroy/two-scoops-of-django-3.x GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 292 files (532.9 KB), approximately 125.6k tokens, and a symbol index with 266 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!