Cookiecutter 是一款快速建立工程模板的 Python 命令行工具,它可以让你选择已有的模板来快速搭建工程项目,同时支持多种语言。
链接:https://github.com/cookiecutter/cookiecutter
安装
在 Python3 环境中使用 pip3 安装
# 先安装 gitpip3 install cookiecutter
找到使用的模板github的 https 地址, 到项目目录下执行:
cookiecutter https://github.com/pydanny/cookiecutter-django.git
按照提示输入,构建项目
project_name [My Awesome Project]: prj_name # 项目目录project_slug [prj_name]: # 项目slugdescription [Behold My Awesome Project!]: a simple website # 项目简介author_name [Daniel Roy Greenfeld]: __qj__ # 作者domain_name [example.com]: ilovestudy.club # 域名email [__qj__@example.com]: # 邮箱version [0.1.0]: # 版本号, 默认 0.1.0Select open_source_license: # 项目 License1 - MIT2 - BSD3 - GPLv34 - Apache Software License 2.05 - Not open sourceChoose from 1, 2, 3, 4, 5 (1, 2, 3, 4, 5) [1]: 1timezone [UTC]: Asia/Shanghai # Django settings 中的 TIME_ZONEwindows [n]: n # 是否是windows 环境use_pycharm [n]: y # 使用 pycharmuse_docker [n]: n # 使用 dockerSelect postgresql_version: # Postgres 数据库版本,cookiecutter 默认只支持 Postgres1 - 11.32 - 10.83 - 9.64 - 9.55 - 9.4Choose from 1, 2, 3, 4, 5 (1, 2, 3, 4, 5) [1]:Select js_task_runner: # js 的运行器1 - None2 - GulpChoose from 1, 2 (1, 2) [1]:Select cloud_provider: # 云服务商1 - AWS2 - GCP3 - NoneChoose from 1, 2, 3 (1, 2, 3) [1]: 3custom_bootstrap_compilation [n]: # 是否自定义 bootstrap 压缩use_compressor [n]: y # 使用 django-compressoruse_celery [n]: y # 使用 Celeryuse_mailhog [n]: # 是否使用 mailhoguse_sentry [n]: # 是否使用 sentry 错误日志监控use_whitenoise [n]: # whitenoise 用来部署静态文件,带有文件压缩功能,使用云CDN时一般会使用whitenoise代替nginxuse_heroku [n]: # 使用 heroku ,国外一个PASS平台use_travisci [n]: # travisci 类似 jekins 用于 持续集成与发布keep_local_envs_in_vcs [y]: n # 是否在本地使用版本控制debug [n]: y[WARNING]: You chose not to use a cloud provider, media files won't be served in production.[SUCCESS]: Project initialized, keep up the good work!
