Full-featured django project start tool.
Project description
Introduction
django-start-tool is a full-featured django project start tool.
Installing
Install and update:
$ pip install -U django-start-tool
Usage
Create base project structure
By default project_name is config and target is . (current directory).
$ django-start
# is equivalent to
$ django-start config .
Structure is the same as django-admin startproject:
.
├── config
│ ├── asgi.py
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
Creating from template
Option: -t <path or url>, --template <path or url>
$ django-start \
> -t /path/to/template
$ django-start \
> -t https://github.com/user/repository/archive/main.zip
For example template have this structure:
/path/to/template
├── .env
├── .gitignore
├── manage.py-tpl
├── Pipfile
├── Pipfile.lock
└── project_name
├── asgi.py-tpl
├── __init__.py
├── settings
│ ├── base.py-tpl
│ ├── development.py
│ ├── __init__.py
│ └── production.py
├── urls.py
└── wsgi.py-tpl
Rendering files
There are two ways to specify which files should be rendered.
Using suffix
All files with -tpl suffix will be renamed with no suffix and rendered.
# base.py-tpl -> base.py
# From
SECRET_KEY = '{{ secret_key }}'
ROOT_URLCONF = '{{ project_name }}.urls'
# To
SECRET_KEY = 'django-insecure-3%=4apmw6jb(+$)x#8gu(3@0*vfzoh+e#jg5rdmkb#u=048qe&' # Key is generated randomly
ROOT_URLCONF = 'config.urls' # By default 'project_name' is 'config'
# .env-tpl -> .env
# From
SECRET_KEY='{{ secret_key }}'
# To
SECRET_KEY='django-insecure-3%=4apmw6jb(+$)x#8gu(3@0*vfzoh+e#jg5rdmkb#u=048qe&' # Key is generated randomly
Using CLI option
Option: -f '<patterns>', --files '<patterns>'.
It takes space-separated glob patterns:
$ django-start \
> -t /path/to/template \
> -f '*.env *.rst Procfile'
Then all matched files will be rendered too.
# .env
# From
SECRET_KEY='{{ secret_key }}'
# To
SECRET_KEY='django-insecure-3%=4apmw6jb(+$)x#8gu(3@0*vfzoh+e#jg5rdmkb#u=048qe&' # Key is generated randomly
Extra configuration parameters
Option: -e '<parameters>', --extra '<parameters>'
It takes space-separated key value pairs which will be available from extra object in Jinja2 template:
$ django-start \
> -t /path/to/template \
> -f '*.env *.rst Procfile' \
> -e 'db_name=postgres db_password=secret! my_var=Hello'
# .env
# From
DB_NAME='{{ extra.db_name }}'
DB_PASSWORD='{{ extra.db_password }}'
VAR='{{ extra.my_var }}'
# To
DB_NAME='postgres'
DB_PASSWORD='secret!'
VAR='Hello'
Excluding directies
Option: -x '<patterns>', --exclude <patterns>
It takes space-separated glob patterns:
$ django-start \
> -t /path/to/template \
> -x '.github'
Then all matched directies will be excluded.
By default it’s __pycache__ or starting with ..
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_start_tool-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad2f3d1ba29e1ff627dcb7feda6aa8b15dfdf406ccd6546abd3579f3d904be55 |
|
MD5 | 519b0f10891cbd728acd483394841de4 |
|
BLAKE2b-256 | 41da7f879f1738091571d773f65718b3d952e32b0feac9ccc2a8f32319147d1f |