django package for auto generating projects
Project description
Project Detail
You can find all technologies we used in our project into these files: * Version: 1.0.0 * Frameworks: - Django 3.2.4 * Libraries: - Django rest framework 3.12.4 - Jinja2 3.0.1 * Language: Python 3.9.4
Git Rules
Sage team Git Rules Policy is available here:
Getting Started
Before creating django 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 .
Next we have to create an sample app that we want to generate code for it (it is required for development. you will run tests on this app)
$ python manage.py startapp products
Now we have to add ‘products’ to INSTALLED_APPS in settings.py
INSTALLED_APPS = [
'products',
]
Install Generator
First install package
$ pip install django-sage-painless
Then add ‘sage_painless’ to INSTALLED_APPS in settings.py
These apps should be in your INSTALLED_APPS:
‘rest_framework’
‘drf_yasg’
‘django_seed’
INSTALLED_APPS = [
'sage_painless',
'rest_framework',
'drf_yasg',
'django_seed',
]
Usage
For generating a whole project you just need a diagram. diagram is a json file that contains information about database tables.
you can find examples of diagram file here
start to generate (it is required for development. you will run tests on this app)
$ python manage.py generate --app products --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 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
Rest API documentation is available at localhost:8000/api/doc/
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/
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
$ python manage.py generate --app products --diagram sage_painless/tests/diagrams/product_diagram.json
run tests
$ python manage.py test sage_painless
Team
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
Hashes for django-sage-painless-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30bfa641a47af3f8d6aa59daf2ea6ab92d1c03c411c4caf86343fc105ad0df2c |
|
MD5 | acd626e5d1a490387a9c63b6b836fb39 |
|
BLAKE2b-256 | 52788f1f1ae21bea64ed2114469d6a38fb6e0b922080edeb749a238408e99f02 |