<h1 align="center">Django hogwarts 🧙♂️</h1>
<h4 align="center">Management commands to generate views, urls and templates</h4>
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 <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 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 <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](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 <your-app-name>
```
### 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 <your-app-name>
```
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 = "<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)
Raw data
{
"_id": null,
"home_page": "https://github.com/adiletto64/django-hogwarts",
"name": "django-hogwarts",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "django,django-utils,codegen",
"author": "adiletto64",
"author_email": "adiletdj19@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/7c/38/938d8e1d15d03e6498d030f9003700a40f5d7e5ae3d86fc4e78c787200c2/django_hogwarts-0.9.0.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">Django hogwarts \ud83e\uddd9\u200d\u2642\ufe0f</h1>\n<h4 align=\"center\">Management commands to generate views, urls and templates</h4>\n\nUse CLI commands to generate:\n- basic create, update, list, detail views\n- urlpatterns from views with REST like path urls\n- form, table, detail templates (Bootstrap and django-crispy-forms by default)\n\n**all commands will respect (will not change) existing code**\n\n---\n\n## Installation\n```shell\n# pip\npip install django-hogwarts\n\n# poetry\npoetry add django-hogwarts\n```\n\nadd `hogwarts` to your `INSTALLED_APPS`:\n``` python\nINSTALLED_APPS = [\n ...\n \"hogwarts\"\n]\n```\n\n## Usage\n> Check [this](./docs/conventions.md) to know what urls will be generated\n### Generate urls.py\nGenerates paths for views from views.py\n```\npython manage.py genurls <your-app-name>\n```\n\nArguments:\n- `--force-app-name`, `fan` override app_name variable in urls.py \n- `--override`, `-o` fully overrides existing code in urls.py (previous code will be deleted)\n- `--single-import`, `-s` instead of importing individual view, imports just module`from . import views`\n\n### Generate views.py\nGenerates create, update, detail, list views for model.\nCheckout the [demo](./docs/gen_views_example.md)\n```\npython manage.py genviews <your-app-name> <model-name>\n```\nArguments\n- `--smart-mode`, `-s` adds login required, sets user for CreateView and checks if client is owner of object in UpdateView\n- `--model-is-namespace`, `-mn` adds success_url with name model as [namespace](https://docs.djangoproject.com/en/4.2/topics/http/urls/#url-namespaces)\n- `--file`, `-f` specify view file (example: \"views/posts_view.py\" or \"new_views.py\") in your app\n\n### Generate tests.py\nIt generates tests from urls.py for CRUD generic views only\n``` \npython manage.py gentests <your-app-name>\n```\n\n### Generate templates\nGenerates templates from `template_name`s from views from given app\n\n**[django-crispy-forms](https://github.com/django-crispy-forms/django-crispy-forms) and\n[crispy-bootstrap5](https://github.com/django-crispy-forms/crispy-bootstrap5) packages are required**\n\n``` \npython manage.py gentemplates <your-app-name>\n```\n\nWant to create own scaffolding templates? \n1. create folder, copy and customize from [this templates](https://github.com/adiletto64/django-hogwarts/tree/master/hogwarts/scaffold)\n2. add that folder to setting `HOGWARTS_SCAFFOLD_FOLDER = \"<your-folder>\"`\n\n### Scaffolding\n\nGenerates views, urls and templates for given app (every model in app)\n\n``` \npython manage.py scaffold <your-app-name>\n```\n\n\n## Roadmap\n- tests generator\n- maybe rest-framework support (let me know in issues)\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Django utilities for codegen and DX improvement",
"version": "0.9.0",
"project_urls": {
"Documentation": "https://django-hogwarts.vercel.app/",
"Homepage": "https://github.com/adiletto64/django-hogwarts",
"Repository": "https://github.com/adiletto64/django-hogwarts"
},
"split_keywords": [
"django",
"django-utils",
"codegen"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "00cd61f468d815b10e1deecfc63ba16a5f6e9144cd981f24300fa0adb12ef8d5",
"md5": "3d62651b280da60575a23a7b3aba74d3",
"sha256": "94167e00b625bfa3c4022e0010167819837b5a3c34f5452468e3d0089de70c1e"
},
"downloads": -1,
"filename": "django_hogwarts-0.9.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3d62651b280da60575a23a7b3aba74d3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 37035,
"upload_time": "2023-12-23T09:11:04",
"upload_time_iso_8601": "2023-12-23T09:11:04.778839Z",
"url": "https://files.pythonhosted.org/packages/00/cd/61f468d815b10e1deecfc63ba16a5f6e9144cd981f24300fa0adb12ef8d5/django_hogwarts-0.9.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7c38938d8e1d15d03e6498d030f9003700a40f5d7e5ae3d86fc4e78c787200c2",
"md5": "6f70ce5e72bf25f5b19a54b6f692abdc",
"sha256": "d8875a4b1131a98eaefc36d4c7997f7f5c0fa070b8b1e46070d072973c4d2bed"
},
"downloads": -1,
"filename": "django_hogwarts-0.9.0.tar.gz",
"has_sig": false,
"md5_digest": "6f70ce5e72bf25f5b19a54b6f692abdc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 23745,
"upload_time": "2023-12-23T09:11:06",
"upload_time_iso_8601": "2023-12-23T09:11:06.693422Z",
"url": "https://files.pythonhosted.org/packages/7c/38/938d8e1d15d03e6498d030f9003700a40f5d7e5ae3d86fc4e78c787200c2/django_hogwarts-0.9.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-23 09:11:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adiletto64",
"github_project": "django-hogwarts",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-hogwarts"
}