Coder Social home page Coder Social logo

xrmx / cookiecutter-djangopackage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pydanny/cookiecutter-djangopackage

1.0 2.0 0.0 259 KB

A cookiecutter template for creating reusable Django packages quickly.

Makefile 14.55% Python 70.58% Batchfile 13.50% HTML 1.37%

cookiecutter-djangopackage's Introduction

Cookiecutter Django Package

image

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.

cookiecutter-djangopackage's People

Contributors

aaronbassett avatar acdha avatar angvp avatar audreyfeldroy avatar bartek avatar bennylope avatar bgro avatar dadoeyad avatar davidastephens avatar dnmellen avatar grantmcconnaughey avatar hackebrot avatar jangeador avatar jgeskens avatar jonathan-s avatar kelseyq avatar leportella avatar luzfcb avatar marcofucci avatar mxsasha avatar parthkolekar avatar purplediane avatar pydanny avatar pyup-bot avatar requires avatar saschwarz avatar ssteinerx avatar therefromhere avatar uranusjr avatar xrmx avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.