• This repository has been archived on 25/Jan/2022
  • Stars
    star
    435
  • Rank 99,399 (Top 2 %)
  • Language
    Python
  • Created about 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cookiecutter template for creating reusable Django packages quickly.

Cookiecutter Django Package

https://travis-ci.org/pydanny/cookiecutter-djangopackage.svg?branch=master

A cookiecutter template for creating reusable Django packages (installable apps) quickly.

Why? Creating reusable Django packages has always been annoying. There are no defined/maintained best practices (especially for setup.py), so you end up cutting and pasting hacky, poorly understood, often legacy code from one project to the other. This template, inspired by cookiecutter-pypackage, is designed to allow Django developers the ability to break free from cargo-cult configuration and follow a common pattern dictated by the experts and maintained here.

Features

  • Sane setup.py for easy PyPI registration/distribution
  • Travis-CI configuration
  • Codecov configuration
  • Tox configuration
  • Sphinx Documentation
  • BSD licensed by default
  • Basic model generation

Usage

First, create your empty repo on Github (in our example below, we would call it blogging_for_humans) and set up your virtual environment with your favorite method.

Note: Your project will be created with README.rst file containing a pypi badge, a travis-ci badge and a link to documentation on readthedocs.io. You don't need to have these accounts set up before using Cookiecutter or cookiecutter-djangopackage.

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

$ pip install cookiecutter

Now run it against this repo:

$ cookiecutter gh:pydanny/cookiecutter-djangopackage

You'll be prompted for some questions, answer them, then it will create a directory that is your new package.

Let's pretend you want to create a reusable Django app called "Blogging-for-Humans", with an app that can be placed in INSTALLED_APPS as "blogging_for_humans". Rather than have to copy/paste from other people's projects and then fight enthusiasm-destroying app layout issues like setup.py configuration and creating test harnesses, you get Cookiecutter to do all the work.

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

It prompts you for information that it uses to create the app, with defaults in square brackets. Answer them:

Cloning into 'cookiecutter-djangopackage'...
remote: Counting objects: 49, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 49 (delta 6), reused 48 (delta 5)
Unpacking objects: 100% (49/49), done.
full_name [Your full name here]: Daniel Roy Greenfeld
email [[email protected]]: [email protected]
github_username [yourname]: pydanny
project_name [dj-package]: Blogging-for-Humans
repo_name [blogging_for_humans]:
app_name [blogging_for_humans]:
project_short_description [Your project description goes here]: A sample Django package
models [Comma-separated list of models]: Scoop, Flavor
django_versions [1.11,2.1]:
version [0.1.0]:
create_example_project [N]:
Select open_source_license:
1 - MIT
2 - BSD
3 - ISCL
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 [1]:

Enter the project and take a look around:

$ cd blogging_for_humans/
$ ls

Create a GitHub repo and push it there:

$ git init
$ git add .
$ git commit -m "first awesome commit"
$ git remote add origin [email protected]:pydanny/blogging_for_humans.git
$ git push -u origin master

Now take a look at your repo. Awesome, right?

It's time to write the code!!!

Running Tests

Code has been written, but does it actually work? Let's find out!

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ python runtests.py

Setting up Travis

You will need to explicitly activate your repo in your Travis CI profile. If the repo isn't showing up, run a manual synchronisation.

Integration with codecov.io

Code coverage is integrated with Codecov. Make sure you have an account and that you've granted access to your repo. In case of a private repo, you will need to generate a token and pass it when submitting coverage.

Register on PyPI

Once you've got at least a prototype working and tests running, it's time to register the app on PyPI:

python setup.py register

Releasing on PyPI

Time to release a new version? Easy!

First, use bumpversion to up the release number:

$ pip install bumpversion
$ bumpversion --current-version VERSION_NUMBER minor --config-file setup.cfg

Where VERSION_NUMBER is the current version, e.g. 0.1.0.

Then run:

$ python setup.py publish

It will answer with something like:

You probably want to also tag the version now:
      git tag -a 0.1.0 -m 'version 0.1.0'
      git push --tags

Go ahead and follow those instructions.

Add to Django Packages

Once you have a release, and assuming you have an account there, just go to https://www.djangopackages.com/packages/add/ and add it there.

Follows Best Practices

This project follows best practices as espoused in Two Scoops of Django: Best Practices for Django 3.x.

More Repositories

1

cached-property

A decorator for caching properties in classes.
Python
688
star
2

django-uni-form

django-uni-form has been deprecated. Please use django-crispy-forms. Link provided in the README.rst
Python
466
star
3

django-wysiwyg

A Django application for making Django textareas rich text editors. Certainly as a template tag and possibly as a form widget.
HTML
465
star
4

dj-notebook

Django + shell_plus + Jupyter notebooks made easy.
Jupyter Notebook
126
star
5

pydanny-event-notes

My notes for the various conferences I attend.
Python
119
star
6

dj-webhooks

Django + Webhooks made Easy
Python
87
star
7

multiple-user-types-django

How to do different user models
Python
73
star
8

webhooks

Python + Webhooks Made Easy
Python
60
star
9

dj-libcloud

Adds easy python 3 and 2.7 support to Django for management of static assets.
Python
53
star
10

simplicity-archive

Converts ReStructuredText into JSON.
Python
47
star
11

django-social-bookmarking

An eggified model based BSD licensed social booking app for Django
Python
47
star
12

django-profiletools

Tools for Profile models in Django.
Python
41
star
13

that

The Anti-Zen of Python
Python
40
star
14

django-party-pack

Sample project that includes sphinx
JavaScript
39
star
15

dj-paginator

Django + Pagination made easy.
Python
36
star
16

contributors

A command-line script to get all the contributors for one or more GitHub projects.
Python
33
star
17

django-tagging-ext

Django Tagging Extensions
Python
31
star
18

dj-ango

Simplifying the import structure of Django.
Python
30
star
19

shortener_project

A Django project for creating and maintaining shortUrls.
Python
25
star
20

pydanny.github.com

My blog and programming site.
HTML
21
star
21

django-blarg

Django 404 and 500 pages the blarg way.
Python
21
star
22

dj-spam

Django + Fighting Spam Made Easy
Python
21
star
23

fastapi-blog

A markdown-powered blog engine and light CMS for FastAPI.
Python
21
star
24

django-wall

This project is functionally dead and is being kept for archival purposes. I suggest use of https://github.com/justquick/django-activity-stream instead.
Python
20
star
25

django-friends-graph

An extension for django-friends that shows the relationships between people in graph format.
JavaScript
20
star
26

restructuredtext

Python
19
star
27

django-la-facebook

Development is now at https://github.com/cartwheelweb/django-la-facebook
Python
18
star
28

refry

Refry is a modern, maintained, typed easy-to-use retry decorator.
Python
18
star
29

django-nosqladmin

NoSQL Admin for Django
Python
16
star
30

cookiecutter-pymodule

Like cookiecutter_pypackage, but for just a module.
Python
14
star
31

whydjango

Python
14
star
32

django-easy-profiles

Many handy django profile tricks to make it easier for developers. PRE-ALPHA: NOT READY FOR USE!
Python
14
star
33

django-registration-bootstrap

Bootstrap friendly pieces for django-registration
Python
13
star
34

daniel.feldroy.com

Roff
11
star
35

simplicity

A straightforward and opinionated cookiecutter template for building Python packages. Inspired by Audrey Roy Greenfeld's seminal work on Cookiecutter and the cookiecutter-pypackage template.
Python
11
star
36

stringtheory

Adds critically unimportant functionality to Python's str type.
Python
10
star
37

pydanny-computer-setup

How I set things up
8
star
38

configure-django

A package for configuring Django in non-traditional environments.
Python
8
star
39

Python-Wars-Solo

I wrote this using AppleBasic about 30 years ago. Now I'm using Python. This game is a total 45 minute hackfest I did back in 2007 so don't make fun of my coding!
Python
8
star
40

plone-extract

An easy to-use script which serializes Plone data so you can import it into another CMS.
8
star
41

simplicity-complexity-example

An example using simplicity and complexity.
JavaScript
8
star
42

pinax-dances

Tutorial example application for building a pinax flash mob dance site
Python
6
star
43

django-widget-override-test-case

Resolved: Test case demonstrating that overriding Django's form widget input.html template fails
Python
6
star
44

pinax-wall

Tutorial group aware wall application
Python
6
star
45

watdarepo

Determines VCS and host service of a repo.
Python
5
star
46

pycon2012-oauth-sprint

Python
5
star
47

receiptify

Uses complexity and simplicity to generate receipts
Python
5
star
48

slides

Various slide decks
Python
4
star
49

pydanny-v2

Vue
4
star
50

old_pydanny

My in-progress personal website, pydanny.com
JavaScript
4
star
51

tag_project

Fork of the Pinax social_project used to work on django-tagging-ext
Python
3
star
52

listo

An enhanced list for Python
Python
3
star
53

friends_project

My test project for friends breakup in Pinax
Python
3
star
54

strings

Python strings for humans
Python
3
star
55

presentations

Python
3
star
56

bookmanager

A project to manage my books and book wishlist.
JavaScript
3
star
57

shortener_netlify

Using netlify to handle short URLs
HTML
3
star
58

python-party-pack

Python
3
star
59

django-naught

Introspection application for Django
Python
3
star
60

Products.humanator

CAPTCHA alternative for Plone 3.x
Python
3
star
61

jupyter-book-epub

Makes it possible for epubs rendered by Jupyter Book (https://jupyterbook.org/) to build epubs with working tables of content.
Python
3
star
62

djadmin2-theme-1995

An simple example of how to build a django-admin2 theme.
Python
3
star
63

django-simplegraph

Automatically exported from code.google.com/p/django-simplegraph
Python
2
star
64

django-uni-form-examples

This provides working examples of django-uni-form in action.
2
star
65

blarg

Python
2
star
66

vue-tailwindcss-starter

Vue
2
star
67

isthisfor

A way to validate your startup idea!
2
star
68

pygments-custom

My personal fork of pygments implemented so I could have a custom theme because I can't figure out how to do this otherwise.
Python
2
star
69

graph_vizualizer

Just some fun hacking to try and model something
Python
2
star
70

roda

JavaScript
2
star
71

map_project

My project to map out applications to each other
Python
2
star
72

oauthlib-examples

Using OAuthLib against various sources.
2
star
73

awod4

1
star
74

pydanny.com

Vue
1
star
75

dj-notebook-slides

JavaScript
1
star
76

Valley-Capoeira

Where we host content and files.
1
star
77

pydanny

1
star
78

django-application-manager

Automatically exported from code.google.com/p/django-application-manager
Python
1
star
79

dynow-trip-2013

1
star
80

arepa

Arepa-making utility
Makefile
1
star
81

mktg

HTML
1
star
82

audreyr.github.com

JavaScript
1
star
83

lsystem-abop

Python
1
star
84

site-2024

CSS
1
star
85

opencomparison.github.com

Github org page for opencomparison
JavaScript
1
star