├── template ├── DESCRIPTION ├── VAR_PACKAGE_NAME │ ├── static │ │ ├── .empty │ │ └── VAR_PACKAGE_NAME │ │ │ └── .empty │ ├── tests │ │ ├── __init__.py │ │ ├── test_app │ │ │ ├── __init__.py │ │ │ ├── models.py │ │ │ └── templates │ │ │ │ ├── 400.html │ │ │ │ └── 500.html │ │ ├── models_tests.py │ │ ├── urls.py │ │ ├── settings.py │ │ └── test_settings.py │ ├── management │ │ ├── __init__.py │ │ └── commands │ │ │ ├── __init__.py │ │ │ └── hello.py │ ├── templatetags │ │ ├── __init__.py │ │ └── VAR_PACKAGE_NAME_tags.py │ ├── templates │ │ └── VAR_PACKAGE_NAME │ │ │ └── .empty │ ├── models.py │ ├── __init__.py │ ├── views.py │ ├── urls.py │ └── admin.py ├── requirements.txt ├── setup.cfg ├── test_requirements.txt ├── AUTHORS ├── .gitignore ├── tox.ini ├── manage.py ├── Makefile ├── MANIFEST.in ├── CHANGELOG.txt ├── .travis.yml ├── runtests.py ├── LICENSE ├── hooks │ └── pre-commit ├── docs │ └── README.md ├── README.rst └── setup.py ├── AUTHORS ├── README.rst └── init.sh /template/DESCRIPTION: -------------------------------------------------------------------------------- 1 | VAR_DESCRIPTION 2 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/static/.empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/management/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/templatetags/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/test_app/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/test_app/models.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/management/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/static/VAR_PACKAGE_NAME/.empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/requirements.txt: -------------------------------------------------------------------------------- 1 | django 2 | django-compat 3 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/templates/VAR_PACKAGE_NAME/.empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/test_app/templates/400.html: -------------------------------------------------------------------------------- 1 | ERROR: 400 2 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/test_app/templates/500.html: -------------------------------------------------------------------------------- 1 | ERROR: 500 2 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/models.py: -------------------------------------------------------------------------------- 1 | """Models for the VAR_PACKAGE_NAME app.""" 2 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __version__ = '0.1' # pragma: no cover 3 | -------------------------------------------------------------------------------- /template/setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = F999,E501,E128,E124 3 | exclude = .git,*/migrations/*,*/static/CACHE/* 4 | -------------------------------------------------------------------------------- /template/test_requirements.txt: -------------------------------------------------------------------------------- 1 | coverage 2 | fabric3 3 | flake8 4 | ipdb 5 | mixer 6 | mock 7 | tox 8 | django-compat 9 | -------------------------------------------------------------------------------- /template/AUTHORS: -------------------------------------------------------------------------------- 1 | Current or previous core committers 2 | 3 | VAR_FULL_NAME 4 | 5 | Contributors (in alphabetical order) 6 | 7 | * Your name could stand here :) 8 | -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | *.coverage 2 | *.egg-info/ 3 | *.pyc 4 | *coverage/ 5 | .tox/ 6 | app_media/ 7 | app_static/ 8 | db.sqlite 9 | dist/ 10 | docs/_build/ 11 | local_settings.py 12 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/models_tests.py: -------------------------------------------------------------------------------- 1 | """Tests for the models of the VAR_PACKAGE_NAME app.""" 2 | # from django.test import TestCase 3 | 4 | # from mixer.backend.django import mixer 5 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/views.py: -------------------------------------------------------------------------------- 1 | """Views for the VAR_PACKAGE_NAME app.""" 2 | # from django.views.generic import TemplateView 3 | 4 | # from . import models 5 | 6 | 7 | # class YourView(TemplateView): 8 | # template_name = 'VAR_PACKAGE_NAME/default.html' 9 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/urls.py: -------------------------------------------------------------------------------- 1 | """URLs to run the tests.""" 2 | from compat import include, url 3 | from django.contrib import admin 4 | 5 | 6 | admin.autodiscover() 7 | 8 | urlpatterns = [ 9 | url(r'^admin/', include(admin.site.urls)), 10 | ] 11 | -------------------------------------------------------------------------------- /template/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py27-django{18,19},py35-django19 3 | 4 | [testenv] 5 | usedevelop = True 6 | deps = 7 | django18: Django>=1.8,<1.9 8 | django19: Django>=1.9,<1.10 9 | -rtest_requirements.txt 10 | commands = python runtests.py 11 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/urls.py: -------------------------------------------------------------------------------- 1 | """URLs for the VAR_PACKAGE_NAME app.""" 2 | # from compat import url 3 | 4 | # from . import views 5 | 6 | 7 | # urlpatterns = [ 8 | # url(r'^$', 9 | # views.YourView.as_view(), 10 | # name='VAR_PACKAGE_NAME_default'), 11 | # ] 12 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/management/commands/hello.py: -------------------------------------------------------------------------------- 1 | from django.core.management.base import BaseCommand 2 | 3 | 4 | class Command(BaseCommand): 5 | args = '' 6 | help = 'Say hello to ' 7 | 8 | def handle(self, *args, **options): 9 | for name in args: 10 | self.stdout.write('Hello %s.' % name) 11 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/templatetags/VAR_PACKAGE_NAME_tags.py: -------------------------------------------------------------------------------- 1 | """Templatetags for the VAR_PACKAGE_NAME app.""" 2 | from django import template 3 | 4 | register = template.Library() 5 | 6 | # @register.filter 7 | # def lower(value): 8 | # """ 9 | # Converts a string into all lowercase 10 | # 11 | # """ 12 | # return value.lower() 13 | -------------------------------------------------------------------------------- /template/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 7 | 'VAR_PACKAGE_NAME.tests.settings') 8 | 9 | from django.core.management import execute_from_command_line 10 | 11 | execute_from_command_line(sys.argv) 12 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Current or previous core committers 2 | 3 | Martin Brochhaus 4 | 5 | Contributors (in alphabetical order) 6 | 7 | * Your name could stand here :) 8 | * Björn Andersson (gaqzi) 9 | * Kit Sunde (Celc) 10 | * Philippe O. Wagner (philippeowagner) 11 | * Robert Węglarek (robertweglarek) 12 | * Yannik Ammann (yannik-ammann) 13 | * Tobias Lorenz (Tyrdall) 14 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/admin.py: -------------------------------------------------------------------------------- 1 | """Admin classes for the VAR_PACKAGE_NAME app.""" 2 | # from django.contrib import admin 3 | 4 | # from . import models 5 | 6 | 7 | # class YourModelAdmin(admin.ModelAdmin): 8 | # list_display = ['some', 'fields', ] 9 | # search_fields = ['some', 'fieds', ] 10 | 11 | # admin.site.register(models.YourModel, YourModelAdmin) 12 | -------------------------------------------------------------------------------- /template/Makefile: -------------------------------------------------------------------------------- 1 | develop: setup-git 2 | pip install "file://`pwd`#egg=VAR_PACKAGE_NAME[dev]" 3 | pip install -e . 4 | pip install -r test_requirements.txt 5 | 6 | setup-git: 7 | git config branch.autosetuprebase always 8 | cd .git/hooks && ln -sf ../../hooks/* ./ 9 | 10 | lint-python: 11 | @echo "Linting Python files" 12 | PYFLAKES_NODOCTEST=1 flake8 VAR_PACKAGE_NAME 13 | @echo "" 14 | -------------------------------------------------------------------------------- /template/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include LICENSE 3 | include DESCRIPTION 4 | include CHANGELOG.txt 5 | include README.md 6 | include tox.ini 7 | include runtests.py 8 | include requirements.txt 9 | include test_requirements.txt 10 | graft VAR_PACKAGE_NAME 11 | global-exclude *.orig *.pyc *.log *.swp local_settings.py 12 | prune VAR_PACKAGE_NAME/tests/coverage 13 | prune VAR_PACKAGE_NAME/.ropeproject 14 | -------------------------------------------------------------------------------- /template/CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | === 0.0.X (onggoing, to be released as 0.1) === 2 | - Initial commit 3 | 4 | 5 | # Suggested file syntax: 6 | # 7 | # === (ongoing) === 8 | # - this is always on top of the file 9 | # - when you release a new version, you rename the last `(ongoing)` to the new 10 | # version and add a new `=== (ongoing) ===` to the top of the file 11 | # 12 | # === 1.0 === 13 | # - a major version is created when the software reached a milestone and is 14 | # feature complete 15 | # 16 | # === 0.2 === 17 | # - a minor version is created when a lot of new features have bene added or 18 | # significant backwards incompatible changes have been made. 19 | -------------------------------------------------------------------------------- /template/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | python: 4 | - "2.7" 5 | - "3.5" 6 | 7 | env: 8 | - DJANGO=django==1.4.* 9 | - DJANGO=django==1.5.* 10 | - DJANGO=django==1.6.* 11 | - DJANGO=django==1.7.* 12 | - DJANGO=django==1.8.* 13 | - DJANGO=django==1.9.* 14 | 15 | install: 16 | - pip install -r test_requirements.txt --use-mirrors 17 | - pip install $DJANGO 18 | - pip install coveralls 19 | 20 | script: 21 | - cd VAR_PACKAGE_NAME/tests 22 | - ./runtests.py 23 | - mv .coverage ../../ 24 | - cd ../../ 25 | 26 | matrix: 27 | exclude: 28 | - python: "3.4" 29 | env: DJANGO=django==1.4.* 30 | 31 | after_success: 32 | - coveralls 33 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | These settings are used by the ``manage.py`` command. 3 | 4 | With normal tests we want to use the fastest possible way which is an 5 | in-memory sqlite database but if you want to create South migrations you 6 | need a persistant database. 7 | 8 | Unfortunately there seems to be an issue with either South or syncdb so that 9 | defining two routers ("default" and "south") does not work. 10 | 11 | """ 12 | from distutils.version import StrictVersion 13 | 14 | import django 15 | 16 | from .test_settings import * # NOQA 17 | 18 | 19 | DATABASES = { 20 | 'default': { 21 | 'ENGINE': 'django.db.backends.sqlite3', 22 | 'NAME': 'db.sqlite', 23 | } 24 | } 25 | 26 | django_version = django.get_version() 27 | if StrictVersion(django_version) < StrictVersion('1.7'): 28 | INSTALLED_APPS.append('south', ) 29 | -------------------------------------------------------------------------------- /template/runtests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | This script is used to run tests, create a coverage report and output the 4 | statistics at the end of the tox run. 5 | To run this script just execute ``tox`` 6 | """ 7 | import re 8 | 9 | from fabric.api import local, warn 10 | from fabric.colors import green, red 11 | 12 | 13 | if __name__ == '__main__': 14 | local('flake8 --ignore=E126 --ignore=W391 --statistics' 15 | ' --exclude=submodules,migrations,build .') 16 | local('coverage run --source="VAR_PACKAGE_NAME" manage.py test -v 2' 17 | ' --traceback --failfast' 18 | ' --settings=VAR_PACKAGE_NAME.tests.settings' 19 | ' --pattern="*_tests.py"') 20 | local('coverage html -d coverage --omit="*__init__*,*/settings/*,' 21 | '*/migrations/*,*/tests/*,*admin*"') 22 | total_line = local('grep -n pc_cov coverage/index.html', capture=True) 23 | percentage = float(re.findall(r'(\d+)%', total_line)[-1]) 24 | if percentage < 100: 25 | warn(red('Coverage is {0}%'.format(percentage))) 26 | print(green('Coverage is {0}%'.format(percentage))) 27 | -------------------------------------------------------------------------------- /template/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) VAR_YEAR VAR_FULL_NAME 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /template/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import glob 4 | import os 5 | import sys 6 | 7 | os.environ['PYFLAKES_NODOCTEST'] = '1' 8 | 9 | # pep8.py uses sys.argv to find setup.cfg 10 | sys.argv = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)] 11 | 12 | # git usurbs your bin path for hooks and will always run system python 13 | if 'VIRTUAL_ENV' in os.environ: 14 | site_packages = glob.glob( 15 | '%s/lib/*/site-packages' % os.environ['VIRTUAL_ENV'])[0] 16 | sys.path.insert(0, site_packages) 17 | 18 | 19 | def main(): 20 | from flake8.main import DEFAULT_CONFIG 21 | from flake8.engine import get_style_guide 22 | from flake8.hooks import run 23 | 24 | gitcmd = "git diff-index --cached --name-only HEAD" 25 | 26 | _, files_modified, _ = run(gitcmd) 27 | 28 | # remove non-py files and files which no longer exist 29 | files_modified = filter( 30 | lambda x: x.endswith('.py') and os.path.exists(x), 31 | files_modified) 32 | 33 | flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG) 34 | report = flake8_style.check_files(files_modified) 35 | 36 | return report.total_errors 37 | 38 | if __name__ == '__main__': 39 | sys.exit(main()) 40 | -------------------------------------------------------------------------------- /template/docs/README.md: -------------------------------------------------------------------------------- 1 | # How to create your Sphinx documentation 2 | 3 | In order to kickstart your Sphinx documentation, please do the following: 4 | 5 | ## Create virtual environment. 6 | 7 | If you haven't done so already, create a virtual environment for this reusable 8 | app like so: 9 | 10 | mkvirtualenv -p python2.7 VAR_PYPI_NAME 11 | pip install Sphinx 12 | deactivate 13 | workon VAR_PYPI_NAME 14 | sphinx-quickstart 15 | 16 | Answer the questions: 17 | 18 | > Root path for the documentation [.]: 19 | > Separate source and build directories (y/N) [n]: y 20 | > Name prefix for templates and static dir [_]: 21 | > Project name: VAR_APP_NAME 22 | > Author name(s): VAR_FULL_NAME 23 | > Project version: 0.1 24 | > Project release [0.1]: 25 | > Source file suffix [.rst]: 26 | > Name of your master document (without suffix) [index]: 27 | > Do you want to use the epub builder (y/N) [n]: 28 | > autodoc: automatically insert docstrings from modules (y/N) [n]: y 29 | > doctest: automatically test code snippets in doctest blocks (y/N) [n]: 30 | > intersphinx: link between Sphinx documentation of different projects (y/N) [n]: y 31 | > todo: write "todo" entries that can be shown or hidden on build (y/N) [n]: y 32 | > coverage: checks for documentation coverage (y/N) [n]: y 33 | > pngmath: include math, rendered as PNG images (y/N) [n]: 34 | > mathjax: include math, rendered in the browser by MathJax (y/N) [n]: 35 | > ifconfig: conditional inclusion of content based on config values (y/N) [n]: y 36 | > viewcode: include links to the source code of documented Python objects (y/N) [n]: y 37 | > Create Makefile? (Y/n) [y]: 38 | > Create Windows command file? (Y/n) [y]: 39 | -------------------------------------------------------------------------------- /template/VAR_PACKAGE_NAME/tests/test_settings.py: -------------------------------------------------------------------------------- 1 | """Settings that need to be set in order to run the tests.""" 2 | import os 3 | 4 | 5 | DEBUG = True 6 | SITE_ID = 1 7 | 8 | APP_ROOT = os.path.abspath( 9 | os.path.join(os.path.dirname(__file__), '..')) 10 | 11 | 12 | DATABASES = { 13 | 'default': { 14 | 'ENGINE': 'django.db.backends.sqlite3', 15 | 'NAME': ':memory:', 16 | } 17 | } 18 | 19 | ROOT_URLCONF = 'VAR_PACKAGE_NAME.tests.urls' 20 | 21 | STATIC_URL = '/static/' 22 | STATIC_ROOT = os.path.join(APP_ROOT, '../app_static') 23 | MEDIA_ROOT = os.path.join(APP_ROOT, '../app_media') 24 | STATICFILES_DIRS = ( 25 | os.path.join(APP_ROOT, 'static'), 26 | ) 27 | 28 | TEMPLATES = [{ 29 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 30 | 'APP_DIRS': True, 31 | 'DIRS': [os.path.join(APP_ROOT, 'tests/test_app/templates')], 32 | 'OPTIONS': { 33 | 'context_processors': ( 34 | 'django.contrib.auth.context_processors.auth', 35 | 'django.template.context_processors.request', 36 | ) 37 | } 38 | }] 39 | 40 | EXTERNAL_APPS = [ 41 | 'django.contrib.admin', 42 | 'django.contrib.admindocs', 43 | 'django.contrib.auth', 44 | 'django.contrib.contenttypes', 45 | 'django.contrib.messages', 46 | 'django.contrib.sessions', 47 | 'django.contrib.staticfiles', 48 | 'django.contrib.sitemaps', 49 | 'django.contrib.sites', 50 | ] 51 | 52 | INTERNAL_APPS = [ 53 | 'VAR_PACKAGE_NAME', 54 | 'VAR_PACKAGE_NAME.tests.test_app', 55 | ] 56 | 57 | INSTALLED_APPS = EXTERNAL_APPS + INTERNAL_APPS 58 | 59 | MIDDLEWARE_CLASSES = [ 60 | 'django.contrib.sessions.middleware.SessionMiddleware', 61 | 'django.middleware.common.CommonMiddleware', 62 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 63 | 'django.middleware.csrf.CsrfViewMiddleware', 64 | ] 65 | 66 | SECRET_KEY = 'foobar' 67 | -------------------------------------------------------------------------------- /template/README.rst: -------------------------------------------------------------------------------- 1 | VAR_APP_NAME 2 | ============ 3 | 4 | VAR_DESCRIPTION 5 | 6 | Installation 7 | ------------ 8 | 9 | To get the latest stable release from PyPi 10 | 11 | .. code-block:: bash 12 | 13 | pip install VAR_PYPI_NAME 14 | 15 | To get the latest commit from GitHub 16 | 17 | .. code-block:: bash 18 | 19 | pip install -e git+git://VAR_GITHUB_REPO.git#egg=VAR_PACKAGE_NAME 20 | 21 | TODO: Describe further installation steps (edit / remove the examples below): 22 | 23 | Add ``VAR_PACKAGE_NAME`` to your ``INSTALLED_APPS`` 24 | 25 | .. code-block:: python 26 | 27 | INSTALLED_APPS = ( 28 | ..., 29 | 'VAR_PACKAGE_NAME', 30 | ) 31 | 32 | Add the ``VAR_PACKAGE_NAME`` URLs to your ``urls.py`` 33 | 34 | .. code-block:: python 35 | 36 | urlpatterns = [ 37 | url(r'^VAR_URL_HOOK/', include('VAR_PACKAGE_NAME.urls')), 38 | ] 39 | 40 | Before your tags/filters are available in your templates, load them by using 41 | 42 | .. code-block:: html 43 | 44 | {% load VAR_PACKAGE_NAME_tags %} 45 | 46 | 47 | Don't forget to migrate your database 48 | 49 | .. code-block:: bash 50 | 51 | ./manage.py migrate VAR_PACKAGE_NAME 52 | 53 | 54 | Usage 55 | ----- 56 | 57 | TODO: Describe usage or point to docs. Also describe available settings and 58 | templatetags. 59 | 60 | 61 | Contribute 62 | ---------- 63 | 64 | If you want to contribute to this project, please perform the following steps 65 | 66 | .. code-block:: bash 67 | 68 | # Fork this repository 69 | # Clone your fork 70 | mkvirtualenv -p python2.7 VAR_PYPI_NAME 71 | make develop 72 | 73 | git co -b feature_branch master 74 | # Implement your feature and tests 75 | git add . && git commit 76 | git push -u origin feature_branch 77 | # Send us a pull request for your feature branch 78 | 79 | In order to run the tests, simply execute ``tox``. This will install two new 80 | environments (for Django 1.8 and Django 1.9) and run the tests against both 81 | environments. 82 | -------------------------------------------------------------------------------- /template/setup.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | """ 3 | Python setup file for the VAR_PACKAGE_NAME app. 4 | 5 | In order to register your app at pypi.python.org, create an account at 6 | pypi.python.org and login, then register your new app like so: 7 | 8 | python setup.py register 9 | 10 | If your name is still free, you can now make your first release but first you 11 | should check if you are uploading the correct files: 12 | 13 | python setup.py sdist 14 | 15 | Inspect the output thoroughly. There shouldn't be any temp files and if your 16 | app includes staticfiles or templates, make sure that they appear in the list. 17 | If something is wrong, you need to edit MANIFEST.in and run the command again. 18 | 19 | If all looks good, you can make your first release: 20 | 21 | python setup.py sdist upload 22 | 23 | For new releases, you need to bump the version number in 24 | VAR_PACKAGE_NAME/__init__.py and re-run the above command. 25 | 26 | For more information on creating source distributions, see 27 | http://docs.python.org/2/distutils/sourcedist.html 28 | 29 | """ 30 | import os 31 | from setuptools import setup, find_packages 32 | import VAR_PACKAGE_NAME as app 33 | 34 | 35 | dev_requires = [ 36 | 'flake8', 37 | ] 38 | 39 | install_requires = open('requirements.txt').read().splitlines() 40 | 41 | 42 | def read(fname): 43 | try: 44 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 45 | except IOError: 46 | return '' 47 | 48 | setup( 49 | name="VAR_PYPI_NAME", 50 | version=app.__version__, 51 | description=read('DESCRIPTION'), 52 | long_description=read('README.rst'), 53 | license='The MIT License', 54 | platforms=['OS Independent'], 55 | keywords='VAR_KEYWORDS', 56 | author='VAR_FULL_NAME', 57 | author_email='VAR_AUTHOR_EMAIL', 58 | url="https://VAR_GITHUB_REPO", 59 | packages=find_packages(), 60 | include_package_data=True, 61 | install_requires=install_requires, 62 | extras_require={ 63 | 'dev': dev_requires, 64 | }, 65 | ) 66 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Django Reusable App Template 2 | ============================ 3 | 4 | This repository aims to help you to kickstart new reusable Django apps within 5 | a few minutes. 6 | 7 | It was presented at PyCon Singapore 2013 for the first time, you can find the 8 | slides of the talk here: https://speakerdeck.com/mbrochh/writing-publishing-and-maintaining-reusable-django-apps 9 | 10 | A video of the talk can be found here: http://youtu.be/a4S1kTJfezA 11 | 12 | In order to kickstart your new reusable app, just do the following 13 | 14 | .. code-block:: bash 15 | 16 | git clone git://github.com/bitmazk/django-reusable-app-template.git your-app-name 17 | cd your-app-name 18 | nano init.sh 19 | # change all variables to your needs 20 | ./init.sh 21 | 22 | The init script will replace all placeholders in the project files in the 23 | ``template`` folder with your desired values. Then it will rename a few 24 | folders into your desired app name. Next it will remove the ``.git`` folder, 25 | move everything from ``template`` into the root folder and create a first 26 | initial commit. Now you have a new reusable app that does nothing, yet. 27 | 28 | After this you can create the virtual environment or your app 29 | 30 | .. code-block:: bash 31 | 32 | mkvirtualenv -p python2.7 your-app-name 33 | make develop 34 | 35 | Now you can run the tests. You might want to modify `tox.ini` so that it only 36 | runs tests for Python/Django versions that you intend to support. 37 | 38 | .. code-block:: bash 39 | 40 | tox 41 | 42 | Or you can initiate the database and preview your app in the browser 43 | 44 | .. code-block:: bash 45 | 46 | # Django < 1.8: 47 | ./manage.py syncdb --all 48 | ./manage.py migrate --fake 49 | 50 | # Django >= 1.8: 51 | ./manage.py migrate 52 | 53 | ./manage.py runserver 54 | 55 | The only URL that is hooked up will be the admin url, so you can open 56 | `localhost:8000/admin/`. 57 | 58 | Once you have implemented your app, you can publish it on the Python Package 59 | Index like so 60 | 61 | .. code-block:: bash 62 | 63 | python setup.py register 64 | python setup.py sdist upload 65 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The variable values here are just examples. Replace them all with real values 3 | # of your own app. 4 | 5 | # Your full name, will appear in AUTHORS, LICENSE and setup.py 6 | VAR_FULL_NAME='Your Name' 7 | 8 | # Your email address, used in setup.py, shown on pypi.python.org 9 | export VAR_AUTHOR_EMAIL='yourmail@gmail.com' 10 | 11 | # The project name as it would appear as the main headline in the README 12 | # You should google for your app name first and make sure that no one else has 13 | # taken it. 14 | VAR_APP_NAME='Django Reusable App Template' 15 | 16 | # The package name, which would be added to INSTALLED_APPS 17 | VAR_PACKAGE_NAME='reusable_app_template' 18 | 19 | # Example URL path the app should be loaded at 20 | VAR_URL_HOOK='app-url' 21 | 22 | # The package name as defined in setup.py - this is also what you would search 23 | # for on pypi.python.org. You should search pypi.python.org first and make sure 24 | # that your package name is not taken already. 25 | VAR_PYPI_NAME='django-reusable-app-template' 26 | 27 | # A short description which will be parsed by pypi.python.org 28 | VAR_DESCRIPTION='A reusable Django app that does nothing much.' 29 | 30 | # Path to your repo on Github (without the .git at the end) 31 | VAR_GITHUB_REPO='github.com/mbrochh/django-reusable-app-template' 32 | 33 | # Keywords for your app, used in setup.py 34 | VAR_KEYWORDS='django, app, reusable' 35 | 36 | # Current year, will be shown in the license file. You can set it to any year 37 | # (i.e. 2001) or just leave this default and compute it automatically 38 | VAR_YEAR=`date +'%Y'` 39 | 40 | # ============================================================================ 41 | 42 | rm -rf .git 43 | rm README.rst 44 | rm AUTHORS 45 | CMD=(find ./template -type f \( ! -iname '*.pyc' ! -iname 'init.sh' \) -print0) 46 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_YEAR#${VAR_YEAR}#g" 47 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_FULL_NAME#${VAR_FULL_NAME}#g" 48 | "${CMD[@]}" | xargs -0 perl -pi -e 's#VAR_AUTHOR_EMAIL#$ENV{VAR_AUTHOR_EMAIL}#g' 49 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_APP_NAME#${VAR_APP_NAME}#g" 50 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_PACKAGE_NAME#${VAR_PACKAGE_NAME}#g" 51 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_PYPI_NAME#${VAR_PYPI_NAME}#g" 52 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_DESCRIPTION#${VAR_DESCRIPTION}#g" 53 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_GITHUB_REPO#${VAR_GITHUB_REPO}#g" 54 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_KEYWORDS#${VAR_KEYWORDS}#g" 55 | "${CMD[@]}" | xargs -0 perl -pi -e "s#VAR_URL_HOOK#${VAR_URL_HOOK}#g" 56 | mv template/VAR_PACKAGE_NAME template/$VAR_PACKAGE_NAME 57 | mv template/$VAR_PACKAGE_NAME/static/VAR_PACKAGE_NAME template/$VAR_PACKAGE_NAME/static/$VAR_PACKAGE_NAME 58 | mv template/$VAR_PACKAGE_NAME/templates/VAR_PACKAGE_NAME template/$VAR_PACKAGE_NAME/templates/$VAR_PACKAGE_NAME 59 | mv template/$VAR_PACKAGE_NAME/templatetags/VAR_PACKAGE_NAME_tags.py template/$VAR_PACKAGE_NAME/templatetags/${VAR_PACKAGE_NAME}_tags.py 60 | 61 | 62 | rm init.sh 63 | mv template/* . 64 | mv template/.gitignore . 65 | mv template/.travis.yml . 66 | rmdir template 67 | git init 68 | git add . 69 | git commit -am "Initial commit" 70 | echo "All done! Don't forget to fix the first headline in README.rst!" 71 | --------------------------------------------------------------------------------