Define models and fields using YAML and generate app for Django with views, forms, templates etc.
Project description
Introduction
Django-make-app will generate code of your Django app from a simple YAML schema. This is similar to manage.py startapp but much powerful.
This will be generated from models definitions:
Admin classes and admin forms
Django REST framework View Sets, Serializers and Router configuration
Django AppConfig
Django System Checks
Forms classes
Models classes
Detail/Delete/Update/Create/List views, urls and templates
Management command example
Dummy filter
Signals and receivers files
TODO tests
Installation
Supported Python versions are: 2.7, 3.4, 3.5, 3.6, pypy and pypy3.
pip install --upgrade django-make-app
Python 3.3 is not supported due to incompatibility of yapf (see: https://github.com/google/yapf#python-versions). If you’re on Python 3.3, you can use this package with option django-make-app generate ... --no-optimize (this will skip yapf).
Usage
If you want to generate app called library, create a file app_schema.yaml in project’s root and define models:
apps:
-
name: library # all files will be generated into library/ directory (will be created)
models:
- User: # model name
- name:char # model field "name" of type "char"
- email:char # model field "email" of type "char"
- Book: # another model
- library:fk # model field "library" of type "foreign key" to "library"
- Article # empty model without fields
-
name: my_another_awesome_app
models:
- City
- Country
You can also print example configuration by executing (or check templates/example.yaml):
django-make-app write_config > app_schema.yaml
Finally to generate source code of your app, execute:
django-make-app generate library
This structure will be generated:
LIBRARY
| admin.py
| api.py
| apps.py
| checks.py
| forms.py
| models.py
| receivers.py
| serializers.py
| signals.py
| urls.py
| views.py
| __init__.py
|
|---management
| | __init__.py
| |
| \---commands
| library_command.py
| __init__.py
|
|---migrations
| __init__.py
|
|---templates
| \---web
| book_delete.html
| book_detail.html
| book_form.html
| book_list.html
| article_delete.html
| article_detail.html
| article_form.html
| article_list.html
| user_delete.html
| user_detail.html
| user_form.html
| user_list.html
|
|---templatetags
| web_tags.py
| __init__.py
|
\---tests
factories.py
test_book.py
test_article.py
test_user.py
__init__.py
Inspiration
License
The MIT License (MIT)
Copyright (c) 2016–2017 Vašek Dohnal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
Built Distribution
File details
Details for the file django_make_app-0.1.3.tar.gz
.
File metadata
- Download URL: django_make_app-0.1.3.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5234800405999927141b2fd279c8d0c33d169727ce9850e7daa83f2eb6d7f16 |
|
MD5 | 5bd2ddc21f426545a9cc07dbe6575e40 |
|
BLAKE2b-256 | 7acd30ae7a1ecf73301c5b3781d0d4e14f6c9415d9e3e97c8f522b636d59bad9 |
File details
Details for the file django_make_app-0.1.3-py2.py3-none-any.whl
.
File metadata
- Download URL: django_make_app-0.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ffe51a816d96032761785d7331a4f1df1dfc8b3a442c72cfeb6bda657dbf51f |
|
MD5 | 5ac40b6cb8fbdbc514911dc5966246b7 |
|
BLAKE2b-256 | e7557d567d8f10fe8f9af4edb0c1a01499d5b6b892767eae500ae71fa669d711 |