Skeleton setup to simplify setting up django project.
Project description
A simple application to quickly setup settings files without too much hassle.
Installation
pip install django-skeleton-setup
Configure Settings and Environment Files
Add “skeleton_setup” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'skeleton_setup', ]
If your application settings uses default WSGI_APPLICATION move to step 4 else to step 3
Set following variable to settings.py.
SKELETON_SITE_ROOT = Path(__file__).resolve().parent
Run python manage.py skeleton_setup to create copy following files:
settings_common.py
settings_local.py
settings_production.py
env_local.env
Add following line to end of settings.py file
from .settings_common import *
Database setup is based on postgres, if other database is used then to avoid runserver error
change DATABASES dict as required
Change the following env file for local development
env_local.env
Edit env files or settings files as per your requirements
Creating a new app provided by skeleton setup
Minimal command similar to startapp of django-admin
python manage.py skeleton_startapp app_name to_path
Parameter “app_name” is required
Parameter “to_path” is optional and is path string value relative to BASE_DIR where you want to create the app
App with following structure will be created:
├── api │ ├── __init__.py │ ├── urls.py │ └── views.py ├── migrations │ └── __init__.py ├── serializers │ └── __init__.py ├── services │ └── __init__.py ├── templates ├── tests │ └── __init__.py ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── model_managers.py ├── models.py ├── signals.py └── urls.py └── utils.py └── views.py
Don’t like app structure provided by this?
No problem you can create your own app structure and use this command
Create a template structure for your application. Use “*.py-tpl” instead of "*.py" files.
Example template:
├── api │ ├── __init__.py-tpl │ ├── urls.py │ └── views.py ├── migrations │ └── __init__.py-tpl ├── tests │ └── __init__.py-tpl ├── utils │ └── __init__.py-tpl ├── static │ └── assets │ └── js │ └── css ├── templates ├── admin.py-tpl ├── apps.py-tpl ├── models.py-tpl └── urls.py-tpl └── views.py-tpl
Add following variable to settings.py
SKELETON_STARTAPP_SOURCE="path/to/your/template/"
Now run the command
python manage.py skeleton_startapp app_name to_path
If you still want to have finer control over the app creation. Extend the following class:
skeleton_startapp.Command
Creating a user app
DEPENDENCIES: djangorestframework
Creates an app for handling users.
Command similar to startapp of django-admin
python manage.py skeleton_startuserapp app_name to_path
The command prompts for:
UserModel [Suggestion: UpperCamelCase] db_table [Suggestion: snake_case] [Optional]
An app is created with given app_name
Modify the app as required
Add it to INSTALLED_APPS in settings.py
Make migrations and migrate
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
File details
Details for the file django-skeleton-setup-0.0.7.tar.gz
.
File metadata
- Download URL: django-skeleton-setup-0.0.7.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eeacf4c87b36d416be6b247fd64649de89749609aa182d4a1e995169b3fdb8a |
|
MD5 | bec516a2fb2d120710bfc3507db1f59b |
|
BLAKE2b-256 | 7a278518435af74e0190daa5f8759ec8f295ec691eb4e496e876efbee1bf60fb |