django-setup-cli helps to produce production ready django project
Project description
django-setup-cli
Django Setup Cli
It takes time to start a Django Project and make it almost production ready. A developer needs to spend a lot of time
installing required libraries, setup database, setup cache as well as hiding secrets, configure settings
file.
With the help of django-setup-cli
a developer can start an almost production ready
project in a minute.
Requirements
python 3.6>
Installation
1. Create a virtual environment and activate
windows
pip install virtualenv
virtualenv venv
<YOUR WORKING DIRECTORY>/venv/scripts/activate
Your Current Working Directory
Ubuntu [Debian]
sudo apt-get install python3-pip
sudo pip3 install virtualenv
virtualenv venv
source venv/bin/activate
you can use any name instead of venv
2. Install django-setup-cli
pip3 install django-setup-cli
Usages
How to use
Usage: django-cli [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
generate Generates YAML File
startproject Starts Django Project
1. startproject
Option 1:
Similar to django-admin startproject
If there's no valid setup.yaml
file in your working directory
django-cli will take some input to start the project
To Start a project use the following command in the shell
django-cli startproject PROJECT_NAME
Note: PROJECT_NAME is optional
>> django-cli startproject ProjectName[Optional]
1. Project Name
Your Project Name: T
2. Install Necessary Libraries
Install Libraries [y/N]: y
1.Install djangorestframework [y/N]: y
2.Install graphene-django [y/N]: y
3.Install django-channels [y/N]: y
4.Install django-localflavor [y/N]: y
5.Install celery [y/N]: y
6.Install whitenoise [y/N]: y
7.Install django-filter [y/N]: y
8.Install django-extensions [y/N]: y
9.Install django-storages [y/N]: y
3. Static File
Create/Use Static File [y/N]: y
4. Template File
Create/Use Template File [y/N]: y
5. Media File
Create/Use Media File [y/N]: y
6. Setup Database
Setup Database [Skip To Use Default] [y/N]: y
1. postgresql
2. mysql
3. maria_db
4. oracle
5. mssql
6. sqlite3
7. django_cockroachdb
Database Engine: 1
Database Name: DATABASE_NAME
Database User: USER
Database Password: PASSWORD
Database Host: localhost
Database Port: 5432
7. Setup Cache
Install Cache [y/N]: y
1. pymemcache
2. redis
3. DatabaseCache
4. FileBasedCache
5. LocMemCache
Cache Engine: 2
Cache Location: LOCATION
After Providing required Information Your Project will be created and you will see following output
1. Installing Required Libraries
installing django
...
...
2. Creating Source Directory
..
3. Creating Project File
Project Setup Complete
Your working directory will have the following files and folders
project
│ README.md
│ .gitignore
│ .env [Django Secrets]
| setup.yaml [django-cli YAML Setup Config File]
└───src
│ manage.py
│
└───PROJECT_NAME
│ asgi.py
│ config.py
│ settings.py
| wsgi.py
| urls.py
Note: Do not delete
.env
file, it will contain database, cache and django secret keys
Option 2:
1. Create a setup.yaml
file
name: TEST_PROJECT
libraries:
- django-rest-framework
- celery
- django-storages
template: true
static: true
media: false
database:
engine: postgresql
user: user
password: password
host: host
port: port
option:
config: psql.cfg
cache:
backend: redis
location: localhost:6532
env:
SECRET_KEY: YOUR_SECRET_KEY
2. Run django-cli startproject
in terminal/shell
django-cli startproject
# Your Project Will be created automatically using the setup.yaml file
Use Environment Variable in setup.yaml
It is possible to use secrets I.E [Database Password, Username, Secret Key] using environment variable
To Hide Secrets Using environment variable
create a cli.env
file in the source directory
And do the following
cli.env
MY_SECRET_KEY=<YOUR_SECRET_KEY>
DATABASE_USER=django_cli
DATABASE_PASSWORD=gonnaCry?
setup.yaml
To use env secret Put $
before your env variable
I.E $SECRET_KEY
name: TEST_PROJECT
libraries:
- django-rest-framework
- celery
- django-storages
template: true
static: true
media: false
database:
engine: postgresql
user: $DATABASE_USER
password: $DATABASE_PASSWORD
host: host
port: port
option:
config: psql.cfg
cache:
backend: redis
location: localhost:6532
env:
SECRET_KEY: $MY_SECRET_KEY
You can target a different env file using
--env
django-cli startproject NewProject --env spider.env
2. generate
django-cli generate PROJECT_NAME --env cli.env
Will generate setup.yaml
file, it will not create project
PROJECT_NAME
and --env
are optional fields
3. install
django-cli install
Will install required libraries also install libraries that are inside requirements.txt
file
@Creator and Maintainer
Khan Asfi Reza
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
File details
Details for the file django-setup-cli-1.0.17.tar.gz
.
File metadata
- Download URL: django-setup-cli-1.0.17.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 206f1036e49d4d64012ad2d306fa4015592335a7c6d006ed708d368a13abf5c6 |
|
MD5 | a0b5bacabd22149e237c135402a882ab |
|
BLAKE2b-256 | 8f7d20936c113b8e61d385b7ca348f364d818504a92ed544e7dfdb25f1676779 |
File details
Details for the file django_setup_cli-1.0.17-py3-none-any.whl
.
File metadata
- Download URL: django_setup_cli-1.0.17-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ea5517cd58d2c77a32fe14373cf977d4b5275a6423321ca08851bcade35601c |
|
MD5 | 20e10a047a115a0831c9321b56fbff4a |
|
BLAKE2b-256 | c2a75d0aa14225a7c5a579afc37c3442e2ce2a959ef95fb97ac0b9016bf3c393 |