Skip to main content

Django utilities for codegen and DX improvement

Project description

Django hogwarts 🧙‍♂️

Management commands to generate views, urls and templates

Use CLI commands to generate:

  • basic create, update, list, detail views
  • urlpatterns from views with REST like path urls
  • form, table, detail templates (Bootstrap and django-crispy-forms by default)

all commands does not remove or override existing views, paths and templates


Installation

# pip
pip install django-hogwarts

# poetry
poetry add --dev django-hogwarts

add hogwarts to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "hogwarts"
]

Usage

Check this to know what urls will be generated

Generate urls.py

python manage.py genurls <your-app-name>

Arguments:

  • --force-app-name, fan override app_name in urls.py

Generate views.py

Check demo

python manage.py genviews <your-app-name> <model-name>

Arguments

  • smart-mode, -s adds login required, sets user for CreateView and checks if client is owner of object in UpdateView
  • model-is-namespace, -mn adds success_url with name model as namespace

Generate templates

django-crispy-forms and crispy-bootstrap5 packages are required

python manage.py gentemplates <your-app-name>

Want to create own scaffolding templates?

  1. create folder, copy and customize from this templates
  2. add that folder to setting HOGWARTS_SCAFFOLD_FOLDER = "<your-folder>"

Roadmap

  • tests generator
  • scaffolding all views, urls and templates from a single command
  • maybe rest-framework support (let me know in issues)

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-hogwarts-0.5.0.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

django_hogwarts-0.5.0-py3-none-any.whl (26.2 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