Slide 1

Slide 1 text

Cookiecutter Django Keith Yang @ Taipei.py 2020 June 新專案⼀直⼀直來?不斷地在造輪⼦?

Slide 2

Slide 2 text

Agenda 順利的話 1. What is Cookiecutter 2. Demo 3. What then Cookiecutter-Django features 4. Demo

Slide 3

Slide 3 text

Cookiecutter Created by Audrey Roy A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python package project template. https:!//github.com/cookiecutter/cookiecutter

Slide 4

Slide 4 text

Features of Cookiecutter 有⼈的常⾒需求,想必你也可有需要 • Cross-platform: Windows, Mac, and Linux are officially supported. • You don't have to know/write Python code to use Cookiecutter • Works with Python 3.6, 3.7, 3.8 and PyPy3. (2… • Project templates can be in any programming language or markup format: Python, JavaScript, Ruby, CoffeeScript, RST, Markdown, CSS, HTML, you name it. You can use multiple languages in the same project template. • Simple command line usage:

Slide 5

Slide 5 text

Sample run • 不過⾸先當然 pip install --user cookiecutter • 然後就挑⼀個 GitHub 上的 repo 跑跑看 cookiecutter gh:audreyr/ cookiecutter-pypackage 它會問你⼀些問題,回答它啊

Slide 6

Slide 6 text

What have it done? • ⼀切都基於 repo 上的 template 所 gen 看⼀下它產⽣的東⻄

Slide 7

Slide 7 text

Cookiecutter Django Created by Daniel Feldroy FEATURES …

Slide 8

Slide 8 text

• For Django 3.0 • Works with Python 3.8 • Renders Django projects with 100% starting test coverage • Twitter Bootstrap v4 (maintained Foundation fork also available) • 12-Factor based settings via django-environ • Secure by default. We believe in SSL. • Optimized development and production settings • Registration via django-allauth • Comes with custom user model ready to go • Optional basic ASGI setup for Websockets • Optional custom static build using Gulp and livereload • Send emails via Anymail (using Mailgun by default or Amazon SES if AWS is selected cloud provider, but switchable) • Media storage using Amazon S3 or Google Cloud Storage • Docker support using docker-compose for development and production (using Traefik with LetsEncrypt support) • Procfile for deploying to Heroku • Instructions for deploying to PythonAnywhere • Run tests with unittest or pytest • Customizable PostgreSQL version • Default integration with pre-commit for identifying simple issues before submission to code review

Slide 9

Slide 9 text

Cookiecutter-Django features - part 1 • For Django 3.0 • Works with Python 3.8 • Renders Django projects with 100% starting test coverage • Twitter Bootstrap v4 (maintained Foundation fork also available)

Slide 10

Slide 10 text

Cookiecutter-Django features - part 2 • 12-Factor based settings via django-environ • Secure by default. We believe in SSL. • Registration via django-allauth • Comes with custom user model ready to go • Optional basic ASGI setup for Websockets

Slide 11

Slide 11 text

Cookiecutter-Django features - part 3 • Send emails via Anymail (using Mailgun by default or Amazon SES if AWS is selected cloud provider, but switchable) • Media storage using Amazon S3 or Google Cloud Storage • Docker support using docker-compose for development and production (using Traefik with LetsEncrypt support)

Slide 12

Slide 12 text

Cookiecutter-Django features - part 4 • Procfile for deploying to Heroku • Instructions for deploying to PythonAnywhere • Run tests with unittest or pytest • Customizable PostgreSQL version

Slide 13

Slide 13 text

Cookiecutter-Django features - more • Django Rest Framework (drf) support • Django compressor • Celery • Sentry

Slide 14

Slide 14 text

跑跑看 • cookiecutter gh:pydanny/ cookiecutter-django

Slide 15

Slide 15 text

最後 demo ⼀下 … ls

Slide 16

Slide 16 text

Do it yourself! ⾃⼰改個 cookiecutter 來重複使⽤吧