├── .gitignore ├── README.md ├── cookiecutter.json └── {{ cookiecutter.repo_name }} ├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── README.rst ├── docs ├── css │ └── extra.css └── index.md ├── mkdocs.yml ├── requirements.txt ├── runtests.py ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── conftest.py └── models.py ├── tox.ini └── {{ cookiecutter.app_name }} └── __init__.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### OSX ### 4 | .DS_Store 5 | .AppleDouble 6 | .LSOverride 7 | 8 | # Icon must end with two \r 9 | Icon 10 | 11 | 12 | # Thumbnails 13 | ._* 14 | 15 | # Files that might appear on external disk 16 | .Spotlight-V100 17 | .Trashes 18 | 19 | # Directories potentially created on remote AFP share 20 | .AppleDB 21 | .AppleDesktop 22 | Network Trash Folder 23 | Temporary Items 24 | .apdisk 25 | 26 | 27 | ### Python ### 28 | # Byte-compiled / optimized / DLL files 29 | __pycache__/ 30 | *.py[cod] 31 | 32 | # C extensions 33 | *.so 34 | 35 | # Distribution / packaging 36 | .Python 37 | env/ 38 | build/ 39 | develop-eggs/ 40 | dist/ 41 | downloads/ 42 | eggs/ 43 | lib/ 44 | lib64/ 45 | parts/ 46 | sdist/ 47 | var/ 48 | *.egg-info/ 49 | .installed.cfg 50 | *.egg 51 | 52 | # PyInstaller 53 | # Usually these files are written by a python script from a template 54 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 55 | *.manifest 56 | *.spec 57 | 58 | # Installer logs 59 | pip-log.txt 60 | pip-delete-this-directory.txt 61 | 62 | # Unit test / coverage reports 63 | htmlcov/ 64 | .tox/ 65 | .coverage 66 | .cache 67 | nosetests.xml 68 | coverage.xml 69 | 70 | # Translations 71 | *.mo 72 | *.pot 73 | 74 | # Django stuff: 75 | *.log 76 | 77 | # Sphinx documentation 78 | docs/_build/ 79 | 80 | # PyBuilder 81 | target/ 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cookiecutter-django-rest-framework 2 | 3 | A cookiecutter template for creating reusable Django REST Framework packages with the best practices quickly. 4 | 5 | ## Features 6 | 7 | - Travis CI configuration 8 | - Tox configuration 9 | - Sane setup.py for easy PyPI registration/distribution 10 | - BSD licensed by default 11 | 12 | ## Usage 13 | 14 | ```bash 15 | $ pip install cookiecutter 16 | $ cookiecutter gh:jpadilla/cookiecutter-django-rest-framework 17 | ``` 18 | 19 | You'll be prompted for some questions, answer them, then it will create a cookiecutter-django-rest-framework with your new package. 20 | 21 | ### Example 22 | 23 | Warning: After this point, change 'José Padilla', 'jpadilla', etc to your own information. 24 | 25 | ```bash 26 | full_name (default is "Your full name here")? José Padilla 27 | email (default is "you@example.com")? hello@jpadilla.com 28 | github_username (default is "yourname")? jpadilla 29 | pypi_project_name (default is "dj-package")? drf-things 30 | repo_name (default is "dj-package")? drf-things 31 | app_name (default is "djpackage")? drfthings 32 | project_short_description (default is "Your project description goes here")? 33 | year (default is "2014")? 34 | version (default is "0.1.0")? 35 | ``` 36 | 37 | Enter the project and take a look around: 38 | 39 | ```bash 40 | $ cd drf-things/ 41 | $ ls 42 | ``` 43 | 44 | Create a GitHub repo and push it there: 45 | 46 | ```bash 47 | $ git init 48 | $ git add . 49 | $ git commit -m "first commit" 50 | $ git remote add origin git@github.com:jpadilla/drf-things.git 51 | $ git push -u origin master 52 | ``` 53 | 54 | ## Register on PyPI 55 | 56 | ```bash 57 | $ python setup.py register 58 | ``` 59 | 60 | ## New release on PyPI 61 | 62 | ```bash 63 | $ python setup.py publish 64 | You probably want to also tag the version now: 65 | git tag -a 0.1.0 -m 'version 0.1.0' 66 | git push --tags 67 | ``` 68 | -------------------------------------------------------------------------------- /cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "full_name": "Your full name here", 3 | "email": "you@example.com", 4 | "github_username": "yourname", 5 | "pypi_project_name": "djangorestframework-package", 6 | "repo_name": "django-rest-framework-package", 7 | "app_name": "rest_framework_package", 8 | "project_short_description": "Your project description goes here", 9 | "year": "2015", 10 | "version": "0.1.0" 11 | } 12 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.db 3 | *~ 4 | .* 5 | 6 | html/ 7 | htmlcov/ 8 | coverage/ 9 | build/ 10 | dist/ 11 | *.egg-info/ 12 | MANIFEST 13 | 14 | bin/ 15 | include/ 16 | lib/ 17 | local/ 18 | 19 | !.gitignore 20 | !.travis.yml 21 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | sudo: false 4 | 5 | env: 6 | - TOX_ENV=py27-flake8 7 | - TOX_ENV=py27-docs 8 | - TOX_ENV=py27-django1.6-drf2.4 9 | - TOX_ENV=py27-django1.6-drf3.0 10 | - TOX_ENV=py27-django1.6-drf3.1 11 | - TOX_ENV=py27-django1.7-drf2.4 12 | - TOX_ENV=py27-django1.7-drf3.0 13 | - TOX_ENV=py27-django1.7-drf3.1 14 | - TOX_ENV=py27-django1.8-drf2.4 15 | - TOX_ENV=py27-django1.8-drf3.0 16 | - TOX_ENV=py27-django1.8-drf3.1 17 | - TOX_ENV=py33-django1.6-drf2.4 18 | - TOX_ENV=py33-django1.6-drf3.0 19 | - TOX_ENV=py33-django1.6-drf3.1 20 | - TOX_ENV=py33-django1.7-drf2.4 21 | - TOX_ENV=py33-django1.7-drf3.0 22 | - TOX_ENV=py33-django1.7-drf3.1 23 | - TOX_ENV=py33-django1.8-drf2.4 24 | - TOX_ENV=py33-django1.8-drf3.0 25 | - TOX_ENV=py33-django1.8-drf3.1 26 | - TOX_ENV=py34-django1.6-drf2.4 27 | - TOX_ENV=py34-django1.6-drf3.0 28 | - TOX_ENV=py34-django1.6-drf3.1 29 | - TOX_ENV=py34-django1.7-drf2.4 30 | - TOX_ENV=py34-django1.7-drf3.0 31 | - TOX_ENV=py34-django1.7-drf3.1 32 | - TOX_ENV=py34-django1.8-drf2.4 33 | - TOX_ENV=py34-django1.8-drf3.0 34 | - TOX_ENV=py34-django1.8-drf3.1 35 | 36 | matrix: 37 | fast_finish: true 38 | 39 | install: 40 | - pip install tox 41 | 42 | script: 43 | - tox -e $TOX_ENV 44 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) {{ cookiecutter.year }}, {{ cookiecutter.full_name }} <{{ cookiecutter.email }}> 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst LICENSE 2 | recursive-exclude * __pycache__ 3 | recursive-exclude * *.py[co] 4 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/README.rst: -------------------------------------------------------------------------------- 1 | {{ cookiecutter.pypi_project_name }} 2 | ====================================== 3 | 4 | |build-status-image| |pypi-version| 5 | 6 | Overview 7 | -------- 8 | 9 | {{ cookiecutter.project_short_description }} 10 | 11 | Requirements 12 | ------------ 13 | 14 | - Python (2.7, 3.3, 3.4) 15 | - Django (1.6, 1.7, 1.8) 16 | - Django REST Framework (2.4, 3.0, 3.1) 17 | 18 | Installation 19 | ------------ 20 | 21 | Install using ``pip``\ … 22 | 23 | .. code:: bash 24 | 25 | $ pip install {{ cookiecutter.pypi_project_name }} 26 | 27 | Example 28 | ------- 29 | 30 | TODO: Write example. 31 | 32 | Testing 33 | ------- 34 | 35 | Install testing requirements. 36 | 37 | .. code:: bash 38 | 39 | $ pip install -r requirements.txt 40 | 41 | Run with runtests. 42 | 43 | .. code:: bash 44 | 45 | $ ./runtests.py 46 | 47 | You can also use the excellent `tox`_ testing tool to run the tests 48 | against all supported versions of Python and Django. Install tox 49 | globally, and then simply run: 50 | 51 | .. code:: bash 52 | 53 | $ tox 54 | 55 | Documentation 56 | ------------- 57 | 58 | To build the documentation, you’ll need to install ``mkdocs``. 59 | 60 | .. code:: bash 61 | 62 | $ pip install mkdocs 63 | 64 | To preview the documentation: 65 | 66 | .. code:: bash 67 | 68 | $ mkdocs serve 69 | Running at: http://127.0.0.1:8000/ 70 | 71 | To build the documentation: 72 | 73 | .. code:: bash 74 | 75 | $ mkdocs build 76 | 77 | .. _tox: http://tox.readthedocs.org/en/latest/ 78 | 79 | .. |build-status-image| image:: https://secure.travis-ci.org/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}.svg?branch=master 80 | :target: http://travis-ci.org/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}?branch=master 81 | .. |pypi-version| image:: https://img.shields.io/pypi/v/{{ cookiecutter.pypi_project_name }}.svg 82 | :target: https://pypi.python.org/pypi/{{ cookiecutter.pypi_project_name }} 83 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/css/extra.css: -------------------------------------------------------------------------------- 1 | body.homepage div.col-md-9 h1:first-of-type { 2 | text-align: center; 3 | font-size: 60px; 4 | font-weight: 300; 5 | margin-top: 0; 6 | } 7 | 8 | body.homepage div.col-md-9 p:first-of-type { 9 | text-align: center; 10 | } 11 | 12 | body.homepage .badges { 13 | text-align: right; 14 | } 15 | 16 | body.homepage .badges a { 17 | display: inline-block; 18 | } 19 | 20 | body.homepage .badges a img { 21 | padding: 0; 22 | margin: 0; 23 | } 24 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/index.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | --- 11 | 12 | # {{ cookiecutter.pypi_project_name }} 13 | 14 | {{ cookiecutter.project_short_description }} 15 | 16 | --- 17 | 18 | ## Overview 19 | 20 | {{ cookiecutter.project_short_description }} 21 | 22 | ## Requirements 23 | 24 | * Python (2.7, 3.3, 3.4) 25 | * Django (1.6, 1.7) 26 | 27 | ## Installation 28 | 29 | Install using `pip`... 30 | 31 | ```bash 32 | $ pip install {{ cookiecutter.pypi_project_name }} 33 | ``` 34 | 35 | ## Example 36 | 37 | TODO: Write example. 38 | 39 | ## Testing 40 | 41 | Install testing requirements. 42 | 43 | ```bash 44 | $ pip install -r requirements.txt 45 | ``` 46 | 47 | Run with runtests. 48 | 49 | ```bash 50 | $ ./runtests.py 51 | ``` 52 | 53 | You can also use the excellent [tox](http://tox.readthedocs.org/en/latest/) testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run: 54 | 55 | ```bash 56 | $ tox 57 | ``` 58 | 59 | ## Documentation 60 | 61 | To build the documentation, you'll need to install `mkdocs`. 62 | 63 | ```bash 64 | $ pip install mkdocs 65 | ``` 66 | 67 | To preview the documentation: 68 | 69 | ```bash 70 | $ mkdocs serve 71 | Running at: http://127.0.0.1:8000/ 72 | ``` 73 | 74 | To build the documentation: 75 | 76 | ```bash 77 | $ mkdocs build 78 | ``` 79 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: {{ cookiecutter.pypi_project_name }} 2 | site_description: {{ cookiecutter.project_short_description }} 3 | repo_url: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }} 4 | site_dir: html 5 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/requirements.txt: -------------------------------------------------------------------------------- 1 | # Minimum Django and REST framework version 2 | Django>=1.6 3 | djangorestframework>=2.4.3 4 | 5 | # Test requirements 6 | pytest-django==2.6 7 | pytest==2.5.2 8 | pytest-cov==1.6 9 | flake8==2.2.2 10 | 11 | # wheel for PyPI installs 12 | wheel==0.24.0 13 | 14 | # MkDocs for documentation previews/deploys 15 | mkdocs==0.11.1 16 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/runtests.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | from __future__ import print_function 3 | 4 | import pytest 5 | import sys 6 | import os 7 | import subprocess 8 | 9 | 10 | PYTEST_ARGS = { 11 | 'default': ['tests'], 12 | 'fast': ['tests', '-q'], 13 | } 14 | 15 | FLAKE8_ARGS = ['{{ cookiecutter.app_name }}', 'tests', '--ignore=E501'] 16 | 17 | 18 | sys.path.append(os.path.dirname(__file__)) 19 | 20 | 21 | def exit_on_failure(ret, message=None): 22 | if ret: 23 | sys.exit(ret) 24 | 25 | 26 | def flake8_main(args): 27 | print('Running flake8 code linting') 28 | ret = subprocess.call(['flake8'] + args) 29 | print('flake8 failed' if ret else 'flake8 passed') 30 | return ret 31 | 32 | 33 | def split_class_and_function(string): 34 | class_string, function_string = string.split('.', 1) 35 | return "%s and %s" % (class_string, function_string) 36 | 37 | 38 | def is_function(string): 39 | # `True` if it looks like a test function is included in the string. 40 | return string.startswith('test_') or '.test_' in string 41 | 42 | 43 | def is_class(string): 44 | # `True` if first character is uppercase - assume it's a class name. 45 | return string[0] == string[0].upper() 46 | 47 | 48 | if __name__ == "__main__": 49 | try: 50 | sys.argv.remove('--nolint') 51 | except ValueError: 52 | run_flake8 = True 53 | else: 54 | run_flake8 = False 55 | 56 | try: 57 | sys.argv.remove('--lintonly') 58 | except ValueError: 59 | run_tests = True 60 | else: 61 | run_tests = False 62 | 63 | try: 64 | sys.argv.remove('--fast') 65 | except ValueError: 66 | style = 'default' 67 | else: 68 | style = 'fast' 69 | run_flake8 = False 70 | 71 | if len(sys.argv) > 1: 72 | pytest_args = sys.argv[1:] 73 | first_arg = pytest_args[0] 74 | if first_arg.startswith('-'): 75 | # `runtests.py [flags]` 76 | pytest_args = ['tests'] + pytest_args 77 | elif is_class(first_arg) and is_function(first_arg): 78 | # `runtests.py TestCase.test_function [flags]` 79 | expression = split_class_and_function(first_arg) 80 | pytest_args = ['tests', '-k', expression] + pytest_args[1:] 81 | elif is_class(first_arg) or is_function(first_arg): 82 | # `runtests.py TestCase [flags]` 83 | # `runtests.py test_function [flags]` 84 | pytest_args = ['tests', '-k', pytest_args[0]] + pytest_args[1:] 85 | else: 86 | pytest_args = PYTEST_ARGS[style] 87 | 88 | if run_tests: 89 | exit_on_failure(pytest.main(pytest_args)) 90 | if run_flake8: 91 | exit_on_failure(flake8_main(FLAKE8_ARGS)) 92 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import re 4 | import os 5 | import sys 6 | from setuptools import setup 7 | 8 | 9 | name = '{{ cookiecutter.pypi_project_name }}' 10 | package = '{{ cookiecutter.app_name }}' 11 | description = '{{ cookiecutter.project_short_description }}' 12 | url = 'https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}' 13 | author = '{{ cookiecutter.full_name }}' 14 | author_email = '{{ cookiecutter.email }}' 15 | license = 'BSD' 16 | 17 | 18 | def get_version(package): 19 | """ 20 | Return package version as listed in `__version__` in `init.py`. 21 | """ 22 | init_py = open(os.path.join(package, '__init__.py')).read() 23 | return re.search("^__version__ = ['\"]([^'\"]+)['\"]", 24 | init_py, re.MULTILINE).group(1) 25 | 26 | 27 | def get_packages(package): 28 | """ 29 | Return root package and all sub-packages. 30 | """ 31 | return [dirpath 32 | for dirpath, dirnames, filenames in os.walk(package) 33 | if os.path.exists(os.path.join(dirpath, '__init__.py'))] 34 | 35 | 36 | def get_package_data(package): 37 | """ 38 | Return all files under the root package, that are not in a 39 | package themselves. 40 | """ 41 | walk = [(dirpath.replace(package + os.sep, '', 1), filenames) 42 | for dirpath, dirnames, filenames in os.walk(package) 43 | if not os.path.exists(os.path.join(dirpath, '__init__.py'))] 44 | 45 | filepaths = [] 46 | for base, filenames in walk: 47 | filepaths.extend([os.path.join(base, filename) 48 | for filename in filenames]) 49 | return {package: filepaths} 50 | 51 | 52 | version = get_version(package) 53 | 54 | 55 | if sys.argv[-1] == 'publish': 56 | if os.system("pip freeze | grep wheel"): 57 | print("wheel not installed.\nUse `pip install wheel`.\nExiting.") 58 | sys.exit() 59 | os.system("python setup.py sdist upload") 60 | os.system("python setup.py bdist_wheel upload") 61 | print("You probably want to also tag the version now:") 62 | print(" git tag -a {0} -m 'version {0}'".format(version)) 63 | print(" git push --tags") 64 | sys.exit() 65 | 66 | 67 | setup( 68 | name=name, 69 | version=version, 70 | url=url, 71 | license=license, 72 | description=description, 73 | author=author, 74 | author_email=author_email, 75 | packages=get_packages(package), 76 | package_data=get_package_data(package), 77 | install_requires=[], 78 | classifiers=[ 79 | 'Development Status :: 2 - Pre-Alpha', 80 | 'Environment :: Web Environment', 81 | 'Framework :: Django', 82 | 'Intended Audience :: Developers', 83 | 'License :: OSI Approved :: BSD License', 84 | 'Operating System :: OS Independent', 85 | 'Natural Language :: English', 86 | 'Programming Language :: Python :: 2', 87 | 'Programming Language :: Python :: 2.7', 88 | 'Programming Language :: Python :: 3', 89 | 'Programming Language :: Python :: 3.3', 90 | 'Programming Language :: Python :: 3.4', 91 | 'Topic :: Internet :: WWW/HTTP', 92 | ] 93 | ) 94 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpadilla/cookiecutter-django-rest-framework/4c5be77ddf089f385bd73aaad49ec039f8628b30/{{ cookiecutter.repo_name }}/tests/__init__.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/tests/conftest.py: -------------------------------------------------------------------------------- 1 | def pytest_configure(): 2 | from django.conf import settings 3 | 4 | settings.configure( 5 | DEBUG_PROPAGATE_EXCEPTIONS=True, 6 | DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 7 | 'NAME': ':memory:'}}, 8 | SITE_ID=1, 9 | SECRET_KEY='not very secret in tests', 10 | USE_I18N=True, 11 | USE_L10N=True, 12 | STATIC_URL='/static/', 13 | ROOT_URLCONF='tests.urls', 14 | TEMPLATE_LOADERS=( 15 | 'django.template.loaders.filesystem.Loader', 16 | 'django.template.loaders.app_directories.Loader', 17 | ), 18 | MIDDLEWARE_CLASSES=( 19 | 'django.middleware.common.CommonMiddleware', 20 | 'django.contrib.sessions.middleware.SessionMiddleware', 21 | 'django.middleware.csrf.CsrfViewMiddleware', 22 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 23 | 'django.contrib.messages.middleware.MessageMiddleware', 24 | ), 25 | INSTALLED_APPS=( 26 | 'django.contrib.auth', 27 | 'django.contrib.contenttypes', 28 | 'django.contrib.sessions', 29 | 'django.contrib.sites', 30 | 'django.contrib.messages', 31 | 'django.contrib.staticfiles', 32 | 33 | 'rest_framework', 34 | 'rest_framework.authtoken', 35 | 'tests', 36 | ), 37 | PASSWORD_HASHERS=( 38 | 'django.contrib.auth.hashers.SHA1PasswordHasher', 39 | 'django.contrib.auth.hashers.PBKDF2PasswordHasher', 40 | 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', 41 | 'django.contrib.auth.hashers.BCryptPasswordHasher', 42 | 'django.contrib.auth.hashers.MD5PasswordHasher', 43 | 'django.contrib.auth.hashers.CryptPasswordHasher', 44 | ), 45 | ) 46 | 47 | try: 48 | import oauth_provider # NOQA 49 | import oauth2 # NOQA 50 | except ImportError: 51 | pass 52 | else: 53 | settings.INSTALLED_APPS += ( 54 | 'oauth_provider', 55 | ) 56 | 57 | try: 58 | import provider # NOQA 59 | except ImportError: 60 | pass 61 | else: 62 | settings.INSTALLED_APPS += ( 63 | 'provider', 64 | 'provider.oauth2', 65 | ) 66 | 67 | # guardian is optional 68 | try: 69 | import guardian # NOQA 70 | except ImportError: 71 | pass 72 | else: 73 | settings.ANONYMOUS_USER_ID = -1 74 | settings.AUTHENTICATION_BACKENDS = ( 75 | 'django.contrib.auth.backends.ModelBackend', 76 | 'guardian.backends.ObjectPermissionBackend', 77 | ) 78 | settings.INSTALLED_APPS += ( 79 | 'guardian', 80 | ) 81 | 82 | try: 83 | import django 84 | django.setup() 85 | except AttributeError: 86 | pass 87 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/tests/models.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpadilla/cookiecutter-django-rest-framework/4c5be77ddf089f385bd73aaad49ec039f8628b30/{{ cookiecutter.repo_name }}/tests/models.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = 3 | py27-{flake8,docs}, 4 | {py27,py33,py34}-django{1.6,1.7,1.8}-drf{2.4,3.0,3.1} 5 | 6 | [testenv] 7 | commands = ./runtests.py --fast 8 | setenv = 9 | PYTHONDONTWRITEBYTECODE=1 10 | deps = 11 | django1.6: Django==1.6.11 12 | django1.7: Django==1.7.8 13 | django1.8: Django==1.8 14 | drf2.4: djangorestframework==2.4.4 15 | drf3.0: djangorestframework==3.0.5 16 | drf3.1: djangorestframework==3.1.3 17 | pytest-django==2.8.0 18 | 19 | [testenv:py27-flake8] 20 | commands = ./runtests.py --lintonly 21 | deps = 22 | pytest==2.7.0 23 | flake8==2.4.0 24 | 25 | [testenv:py27-docs] 26 | commands = mkdocs build 27 | deps = 28 | mkdocs>=0.11.1 29 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/{{ cookiecutter.app_name }}/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '{{ cookiecutter.version }}' 2 | --------------------------------------------------------------------------------