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'
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.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c5070b8216190ffbdeee5eafd74ae5e18ee74ad0bf5a757b0c626d7601e2136 |
|
MD5 | 5f5a43b791019c189ee2ffc207e9818b |
|
BLAKE2b-256 | a20504524066c7ba71c0f7268670d948419d53bef9c7b46a585d9b7ea48fba16 |