Skip to main content

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

  1. Add “skeleton_setup” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'skeleton_setup',
    ]
  2. If your application settings uses default WSGI_APPLICATION move to step 4 else to step 3

  3. Set following variable to settings.py.

    SKELETON_SITE_ROOT = Path(__file__).resolve().parent

  4. Run python manage.py skeleton_setup to create copy following files:

    • settings_common.py

    • settings_local.py

    • settings_production.py

    • env_local.env

  5. Add following line to end of settings.py file

    from .settings_common import *

  6. Database setup is based on postgres, if other database is used then to avoid runserver error

    change DATABASES dict as required

  7. Change the following env file for local development

    env_local.env

  1. Edit env files or settings files as per your requirements

Creating a new app provided by skeleton setup

  1. Minimal command similar to startapp of django-admin

    python manage.py skeleton_startapp app_name to_path

  2. Parameter “app_name” is required

  3. Parameter “to_path” is optional and is path string value relative to BASE_DIR where you want to create the app

  4. 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?

  1. No problem you can create your own app structure and use this command

  2. Create a template structure for your application. Use “*.py-tpl” instead of "*.py" files.

  3. 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
  4. Add following variable to settings.py

    SKELETON_STARTAPP_SOURCE="path/to/your/template/"

  5. Now run the command

    python manage.py skeleton_startapp app_name to_path

  6. 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.

  1. Command similar to startapp of django-admin

    python manage.py skeleton_startuserapp app_name to_path

  2. The command prompts for:

    UserModel [Suggestion: UpperCamelCase]
    
    db_table [Suggestion: snake_case] [Optional]
  3. An app is created with given app_name

  1. Modify the app as required

  2. Add it to INSTALLED_APPS in settings.py

  3. Make migrations and migrate

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-skeleton-setup-0.0.7.tar.gz (14.7 kB view details)

Uploaded Source

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

Hashes for django-skeleton-setup-0.0.7.tar.gz
Algorithm Hash digest
SHA256 1eeacf4c87b36d416be6b247fd64649de89749609aa182d4a1e995169b3fdb8a
MD5 bec516a2fb2d120710bfc3507db1f59b
BLAKE2b-256 7a278518435af74e0190daa5f8759ec8f295ec691eb4e496e876efbee1bf60fb

See more details on using hashes here.

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