Giter VIP home page Giter VIP logo

django-hogwarts's Introduction

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 will respect (will not change) existing code


Installation

# pip
pip install django-hogwarts

# poetry
poetry add django-hogwarts

add hogwarts to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "hogwarts"
]

Usage

Check this to know what urls will be generated

Generate urls.py

Generates paths for views from views.py

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

Arguments:

  • --force-app-name, fan override app_name variable in urls.py
  • --override, -o fully overrides existing code in urls.py (previous code will be deleted)
  • --single-import, -s instead of importing individual view, imports just modulefrom . import views

Generate views.py

Generates create, update, detail, list views for model. Checkout the 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
  • --file, -f specify view file (example: "views/posts_view.py" or "new_views.py") in your app

Generate tests.py

It generates tests from urls.py for CRUD generic views only

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

Generate templates

Generates templates from template_names from views from given app

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>"

Scaffolding

Generates views, urls and templates for given app (every model in app)

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

Roadmap

  • tests generator
  • maybe rest-framework support (let me know in issues)

Development

Before all create config folder and copy everything from example_config to config folder

django-hogwarts's People

Contributors

adiletto64 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.