Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adiletto64/django-hogwarts
Django CRUD codegenerator
https://github.com/adiletto64/django-hogwarts
devtools django django-development django-framework
Last synced: about 1 month ago
JSON representation
Django CRUD codegenerator
- Host: GitHub
- URL: https://github.com/adiletto64/django-hogwarts
- Owner: adiletto64
- Created: 2023-06-23T13:43:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-23T09:18:23.000Z (about 1 year ago)
- Last Synced: 2024-04-26T02:04:03.213Z (8 months ago)
- Topics: devtools, django, django-development, django-framework
- Language: Python
- Homepage:
- Size: 592 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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
```shell
# pip
pip install django-hogwarts# poetry
poetry add django-hogwarts
```add `hogwarts` to your `INSTALLED_APPS`:
``` python
INSTALLED_APPS = [
...
"hogwarts"
]
```## Usage
> Check [this](./docs/conventions.md) to know what urls will be generated
### Generate urls.py
Generates paths for views from views.py
```
python manage.py genurls
```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 module`from . import views`### Generate views.py
Generates create, update, detail, list views for model.
Checkout the [demo](./docs/gen_views_example.md)
```
python manage.py genviews
```
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](https://docs.djangoproject.com/en/4.2/topics/http/urls/#url-namespaces)
- `--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
```### Generate templates
Generates templates from `template_name`s from views from given app**[django-crispy-forms](https://github.com/django-crispy-forms/django-crispy-forms) and
[crispy-bootstrap5](https://github.com/django-crispy-forms/crispy-bootstrap5) packages are required**```
python manage.py gentemplates
```Want to create own scaffolding templates?
1. create folder, copy and customize from [this templates](https://github.com/adiletto64/django-hogwarts/tree/master/hogwarts/scaffold)
2. add that folder to setting `HOGWARTS_SCAFFOLD_FOLDER = ""`### Scaffolding
Generates views, urls and templates for given app (every model in app)
```
python manage.py scaffold
```## 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