A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.
Project description
Django Sage Painless
The django-sage-painless is a valuable package based on Django Web Framework & Django Rest Framework for high-level and rapid web development. The introduced package generates Django applications. After completing many projects, we concluded that any basic project and essential part is its database structure. You can give the database schema in this package and get some parts of the Django application, such as API, models, admin, signals, model cache, setting configuration, mixins, etc. All of these capabilities come with a unit test. So you no longer have to worry about the simple parts of Django, and now you can write your advanced services in Django. The django-sage-painless dramatically speeds up the initial development of your projects. Documentation of this package is available in readthedocs.
Vision
However, we intend to make it possible to use it in projects that are in-progress.
Why Painless
We used the name painless instead of the Django code generator because this package allows you to reach your goals with less effort.
Project Detail
- Language: Python > 3.6
- Framework: Django > 3.1
Getting Started
Before creating Djagno project you must first create virtualenv.
$ python3.9 -m pip install virtualenv
$ python3.9 -m virtualenv venv
To activate virtualenvironment in ubuntu:
$ source venv/bin/activate
To deactive vritualenvironment use:
$ deactivate
Start Project
First create a Django project
$ mkdir GeneratorTutorials
$ cd GeneratorTutorials
$ django-admin startproject kernel .
Install Generator
First install package
$ pip install django-sage-painless
Then add 'sage_painless' to INSTALLED_APPS in settings.py
TIP: You do not need to install the following packages unless you request to automatically generate an API or API documentation.
However, you can add following apps in your INSTALLED_APPS:
- rest_framework
- drf_yasg
- django_seed
INSTALLED_APPS = [
'sage_painless',
'rest_framework',
'drf_yasg',
'django_seed',
]
Usage
To generate a Django app you just need a diagram in JSON format. diagram is a json file that contains information about database tables.
start to generate (it is required for development. you will run tests on this app)
- First validate your diagram format. It will raise errors if your diagram format is incorrect.
$ python manage.py validate_diagram --diagram <path to diagram>
- Now you can generate code (you need generate diagram json file)
$ python manage.py generate --diagram <path to diagram>
- You can generate deploy config files (you need a deploy diagram json file)
$ python manage.py deploy --diagram <path to deploy diagram>
- You can generate doc files (README, etc)
$ python manage.py docs --diagram <path to diagram>
Here system will ask you what you want to generate for your app.
- If you generated api you have to add app urls to main urls.py:
urlpatterns = [
path('api/', include('products.api.urls')),
]
- You have to migrate your new models
$ python manage.py makemigrations
$ python manage.py migrate
- You can run tests for your app
$ python manage.py test products
- Django run server
$ python manage.py runserver
- For support Rest API doc add this part to your urls.py
from rest_framework.permissions import AllowAny
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(
title="Rest API Doc",
default_version='v1',
description="Auto Generated API Docs",
license=openapi.License(name="S.A.G.E License"),
),
public=True,
permission_classes=(AllowAny,),
)
urlpatterns = [
path('api/doc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-swagger-ui'),
]
- Rest API documentation is available at
localhost:8000/api/doc/
How to Contribute
Run project tests before starting to develop
products
app is required for running tests
$ python manage.py startapp products
INSTALLED_APPS = [
'products',
]
-
you have to generate everything for this app
-
diagram file is available here: Diagram
-
download diagram file and generate test app using this commend
$ python manage.py generate --diagram tests/diagrams/product_diagram.json
- run tests
$ python manage.py test sage_painless
Git Rules
S.A.G.E. team Git Rules Policy is available here:
Team
Sepehr Akbarazadeh Maintainer | Mehran Rahmanzadeh Maintainer |
Version 1
- generate README.md
- db encryption
- video streaming
- improve test generation
- coverage & tox
- deployment questionnaire
- management command
- docker
- gunicorn, uwsgi, etc
- nginx configuration
- commit generation
- GitHub repo integration
- CI CD
- Database Support (postgres, mysql, sqlite, sql server)
- security config and check
- seo
- graphql
- package manager support
Version 2
- Django admin generator
- modular setting
- mock data generator
- file field svg support
- image field enhancement
- traditional mixins
- decorator signals
- logging configuration
- sentry support
- monitoring feature (prometheus)
- track data history
- stream upload
- CORS config
- mongo support
- Elastic search configuration
- cache support (+Memcache)
- error handlers (2xx, 3xx, 4xx, 5xx)
- django forms support
- django view support
- image compression support
- debug tools support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-sage-painless-1.14.3.tar.gz
.
File metadata
- Download URL: django-sage-painless-1.14.3.tar.gz
- Upload date:
- Size: 51.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e65fad59d793e651efa5a43973ee5b7f64387295aa18e602587d1dc2098e6cc5 |
|
MD5 | 65782046b1a4fe6b69c71d2b7748e146 |
|
BLAKE2b-256 | cce373ca65755a113e93682d52531398542ade6961bb656812a6f492ac7e1334 |