当前位置: 首页 > 软件库 > 云计算 > >

cookiecutter-django

授权协议 BSD-3-Clause License
开发语言 Python
所属分类 云计算
软件类型 开源软件
地区 不详
投 递 者 程磊
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Cookiecutter Django

Updates

Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstartingproduction-ready Django projects quickly.

Features

  • For Django 3.1
  • Works with Python 3.9
  • 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

Optional Integrations

These features can be enabled during initial project setup.

  • Serve static files from Amazon S3, Google Cloud Storage or Whitenoise
  • Configuration for Celery and Flower (the latter in Docker setup only)
  • Integration with MailHog for local email testing
  • Integration with Sentry for error logging

Constraints

  • Only maintained 3rd party libraries are used.
  • Uses PostgreSQL everywhere (10.16 - 13.2)
  • Environment variables for configuration (This won't work with Apache/mod_wsgi).

Support this Project!

This project is run by volunteers. Please support them in their efforts to maintain and improve Cookiecutter Django:

  • Daniel Roy Greenfeld, Project Lead (GitHub, Patreon): expertise in Django and AWS ELB.
  • Nikita Shupeyko, Core Developer (GitHub): expertise in Python/Django, hands-on DevOps and frontend experience.

Projects that provide financial support to the maintainers:


Two Scoops of Django

Two Scoops of Django 3.x is the best ice cream-themed Django reference in the universe!

pyup

pyup

Pyup brings you automated security and dependency updates used by Google and other organizations. Free for open source projects!

Usage

Let's pretend you want to create a Django project called "redditclone". Rather than using startprojectand then editing the results to include your name, email, and various configuration issues that always get forgotten until the worst possible moment, get cookiecutter to do all the work.

First, get Cookiecutter. Trust me, it's awesome:

$ pip install "cookiecutter>=1.7.0"

Now run it against this repo:

$ cookiecutter https://github.com/cookiecutter/cookiecutter-django

You'll be prompted for some values. Provide them, then a Django project will be created for you.

Warning: After this point, change 'Daniel Greenfeld', 'pydanny', etc to your own information.

Answer the prompts with your own desired options. For example:

Cloning into 'cookiecutter-django'...
remote: Counting objects: 550, done.
remote: Compressing objects: 100% (310/310), done.
remote: Total 550 (delta 283), reused 479 (delta 222)
Receiving objects: 100% (550/550), 127.66 KiB | 58 KiB/s, done.
Resolving deltas: 100% (283/283), done.
project_name [Project Name]: Reddit Clone
project_slug [reddit_clone]: reddit
author_name [Daniel Roy Greenfeld]: Daniel Greenfeld
email [you@example.com]: pydanny@gmail.com
description [Behold My Awesome Project!]: A reddit clone.
domain_name [example.com]: myreddit.com
version [0.1.0]: 0.0.1
timezone [UTC]: America/Los_Angeles
use_whitenoise [n]: n
use_celery [n]: y
use_mailhog [n]: n
use_sentry [n]: y
use_pycharm [n]: y
windows [n]: n
use_docker [n]: n
use_heroku [n]: y
use_compressor [n]: y
Select postgresql_version:
1 - 13.2
2 - 12.6
3 - 11.11
4 - 10.16
Choose from 1, 2, 3, 4, 5 [1]: 1
Select js_task_runner:
1 - None
2 - Gulp
Choose from 1, 2 [1]: 1
Select cloud_provider:
1 - AWS
2 - GCP
3 - None
Choose from 1, 2, 3 [1]: 1
custom_bootstrap_compilation [n]: n
Select open_source_license:
1 - MIT
2 - BSD
3 - GPLv3
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 [1]: 1
keep_local_envs_in_vcs [y]: y
debug[n]: n

Enter the project and take a look around:

$ cd reddit/
$ ls

Create a git repo and push it there:

$ git init
$ git add .
$ git commit -m "first awesome commit"
$ git remote add origin git@github.com:pydanny/redditclone.git
$ git push -u origin master

Now take a look at your repo. Don't forget to carefully look at the generated README. Awesome, right?

For local development, see the following:

Community

  • Have questions? Before you ask questions anywhere else, please post your question on Stack Overflow under the cookiecutter-django tag. We check there periodically for questions.
  • If you think you found a bug or want to request a feature, please open an issue.
  • For anything else, you can chat with us on Slack.

For Readers of Two Scoops of Django

You may notice that some elements of this project do not exactly match what we describe in chapter 3. The reason for that is this project, amongst other things, serves as a test bed for trying out new ideas and concepts. Sometimes they work, sometimes they don't, but the end result is that it won't necessarily match precisely what is described in the book I co-authored.

For pyup.io Users

If you are using pyup.io to keep your dependencies updated and secure, use the code cookiecutter during checkout to get 15% off every month.

"Your Stuff"

Scattered throughout the Python and HTML of this project are places marked with "your stuff". This is where third-party libraries are to be integrated with your project.

Releases

Need a stable release? You can find them at https://github.com/cookiecutter/cookiecutter-django/releases

Not Exactly What You Want?

This is what I want. It might not be what you want. Don't worry, you have options:

Fork This

If you have differences in your preferred setup, I encourage you to fork this to create your own version.Once you have your fork working, let me know and I'll add it to a 'Similar Cookiecutter Templates' list here.It's up to you whether or not to rename your fork.

If you do rename your fork, I encourage you to submit it to the following places:

  • cookiecutter so it gets listed in the README as a template.
  • The cookiecutter grid on Django Packages.

Submit a Pull Request

We accept pull requests if they're small, atomic, and make our own project developmentexperience better.

Articles

Have a blog or online publication? Write about your cookiecutter-django tips and tricks, then send us a pull request with the link.

Code of Conduct

Everyone interacting in the Cookiecutter project's codebases, issue trackers, chatrooms, and mailing lists is expected to follow the PyPA Code of Conduct.

  • 以下介绍的是 cookiecutter-django 项目布局模板。 其它类似的项目模板可以到 这里 找到。 Django 1.8 默认生成的布局 生成命令: $ django-admin.py startproject mysite $ cd mysite $ django-admin.py startapp my_app 生成的布局: mysite/ manage.py my

  • 目录 一、cookie介绍  1、cookie的特点  2、cookie的类型  3、cookie产生流程 图文解析

  • INFO Cookiecutter 是一个通过项目模板创建项目的命令行工具,用于构建Python、Java、JavaScript等项目。 传送门 安装 cookiecutter pip install cookiecutter 运行指定项目模板并根据提示创建项目 cookiecutter https://github.com/pydanny/cookiecutter-django 执行过程

  • 我用max_age这样设置 set_cookie(‘uname’, uname, max_age=60*1) 是没有问题的,cookie会定时失效 (max_age是相对时间) 用expires过期时间设置,试过很多写法,都无法定时失效 set_cookie(‘uname’, uname, expires=10) (相对时间) 或 timeout = datetime.datetime.now()

  • Cookie: Cookie,有时也用其复数形式Cookies,指某些网站为了辨别用户身份、进行session跟踪而储存在用户本地终端上的数据(通常经过加密)。Cookie最早是网景公司的前雇员Lou Montulli在1993年3月的发明。Cookie是由服务器端生成,发送给User-Agent(一般是浏览器),浏览器会将Cookie的key/value保存到某个目录下的文本文件内,下次请求同一

  • django最佳目录结构 Cloning into 'cookiecutter-django'... remote: Counting objects: 550, done. remote: Compressing objects: 100% (310/310), done. remote: Total 550 (delta 283), reused 479 (delta 222) Receivi

  • Cookie Cookie名称和值可以由服务器端开发自己定义,这样服务器可以知道该用户是否是合法用户以及是否需要重新登录等。服务器可以利用Cookies包含信息的任意性来筛选并经常性维护这些信息,以判断在HTTP传输中的状态。Cookies最典型记住用户名。 cookie数据存放在客户的浏览器(客户端)上 1、设置Cookie 常用参数: key: 这个cookie的key。 value: 这个c

  •   应用名/views.py(视图,视图函数): from django.shortcuts import render from django.http import HttpResponse from datetime import datetime,timedelta # 视图函数。 设置cookie def set_cookie(request): response = Htt

  • 使用cookiecutter创建django项目 下载安装: pip install cookiecutter cookiecutter https://github.com/pydanny/cookiecutter-django 在接下来会出现一系列配置选项: 项目生成选项 项目名: 您的项目允许使用人类可读的名称,大写字母和空格。 project_slug: 您的项目的slug没有破折号或空格

 相关资料
  • Cookiecutter 是一款快速建立工程模板的Python命令行工具。它可以让你快速从模板中建立工程,目前有 Python、C、Common Lisp、JS、LaTeX/XeTeX、Berkshelf-Vagrant 和 HTML 的模板。 从 cookiecutter-pypackage.git 中的模板创建工程,你可以输入一些值, 然后它会在当前工作目录下为你创建一些 Python 包。

  • Cookiecutter Django-Vue Powered by Cookiecutter,inspired by Cookiecutter Django. Features Docker 12 Factor Server: Nginx Frontend: Vue + vue-cli + PWA Backend: Django Database: PostgreSQL API: REST or

  • cookiecutter-django-rest a factory for building bleeding edge, best practiced, scalable, rest apis You need to make a scalable api on a deadline. You deeply care about the quality of your work.cookiec

  • cookiecutter-flask A Flask template for cookiecutter. (Supports Python ≥ 3.6) See this repo for an example project generated from the most recent version of the template. Use it now Docker (This is th

  • cookiecutter-flask-restful Cookiecutter template for flask restful, including blueprints, application factory, and more Introduction This cookie cutter is a very simple boilerplate for starting a REST

  • Table of Contents This article consists of the following sections. Table of Contents Features Introduction Requirements Quick start Initial directories and files Makefile targets Working with Docker c