name
: Django Package Ecosystem: cookiecutter-djangopackage
align
: center
alt
: Django Package Ecosystem: cookiecutter-djangopackage
target
: https://www.pydanny.com/how-to-create-installable-django-packages.html
What I mean by an \"installable Django package\": a reusable component that can be shared across Django projects, allowing us to combine our own efforts with others. Some examples include:
Ever want to quickly create a similarly installable Django package to submit to PyPI and Django Packages? One that goes beyond the basics described in the Django tutorial? Specifically, a package that includes:
django-admin.py startapp
that are hard to remember.Well, here's how I do it.
cookiecutter-djangopackage is a Cookiecutter template for creating reusable Django packages. Using it is easy:
First, get Cookiecutter. Trust me, it's awesome:
$ pip install cookiecutter
Now run it against this repo:
$ cookiecutter https://github.com/pydanny/cookiecutter-djangopackage.git
You'll be prompted to enter some values. Enter them. Then an installable Django package will be built for you.
Warning: app_name
must be a valid Python module name or you will
have issues on imports.
Enter the new package (in my case, I called it 'newpackage') and look
around. Open up the AUTHORS.rst
, setup.py
, or README.rst
files and
you'll see your input inserted into the appropriate locations.
Speaking of the README.rst
, that file includes instructions for
putting the new package on PyPI and Django
Packages.
newpackage
├── .editorconfig
├── .gitignore
├── .travis.yml
├── AUTHORS.rst
├── CONTRIBUTING.rst
├── HISTORY.rst
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.rst
├── newpackage
│ ├── __init__.py
│ ├── models.py
│ ├── static
│ │ ├── css
│ │ │ └── newpackage.css
│ │ ├── img
│ │ │ └── .gitignore
│ │ └── js
│ │ └── newpackage.js
│ └── templates
│ └── cheese
│ └── base.html
├── docs
│ ├── Makefile
│ ├── authors.rst
│ ├── conf.py
│ ├── contributing.rst
│ ├── history.rst
│ ├── index.rst
│ ├── installation.rst
│ ├── make.bat
│ ├── readme.rst
│ └── usage.rst
├── requirements-test.txt
├── requirements.txt
├── requirements_dev.txt
├── runtests.py
├── setup.cfg
├── setup.py
├── tests
│ ├── __init__.py
│ └── test_models.py
└── tox.ini
Now, instead of monkeying around for awhile doing copy/paste package setup, I'm immediately ready to write code.
cookiecutter-djangopackage does a lot, but even with its tight focus on package creation it could do more. Some of the things I would love to see included in the future:
django.test
with py.test
.Try it out and let me know what you think. I'm open to new ideas and receiving pull requests.
Tags: python python3 django cheatsheet ppoftw djangopackages
If you read this far, you might want to follow me on twitter or github and subscribe via email below (I'll email you new articles when I publish them).
python django pycon howto twoscoops book audrey class-based-views holidays blog rant python3 resolutions friends family djangocon django-rest-framework capoeira ppoftw cheatsheet eventbrite travel forms hackathon api mongodb argentina cookiecutter pypi flask travel tips for geeks LaTeX pycon-2013-guide meme javascript pyladies ruby philippines europe setup tools consumernotebook markdown pydiversity pypy nasa nodejs clojure php sprint LA Consumer-Notebook OAuth heroku review australia Vue.js mountain coreapi colombia cryptocurrency bitcoin eskrima postgresql djangopackages Cartwheel Web training Two Scoops Academy faceoff RestructuredText brambles packaging binstar conda halloween pumpkin ingredients recipe barcamp WhartonWC jinja2 surgery pyramid europython filepicker joke paypal gondor dotcloud Los Angeles lahackthons casestudy rails vs djangodash science dsf functions meteor perl la wsgi lahackathons los-angeles usability css
If you read this far, you might want to follow me on twitter or github and subscribe via email below (I'll email you new articles when I publish them).
Content Copyright © 2012-2018 Daniel Greenfeld. Proudly harnessed by Mountain, powered by Flask, and rendered by Frozen Flask, all of which take great advantage of Python.
Comments