Skip to main content

Full-featured django project start tool.

Project description

PyPI License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-start-tool-0.3.3.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

django_start_tool-0.3.3-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page