A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.

Overview

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.

 

SageTeam

License PyPI release Supported Python versions Supported Django versions Documentation Build Last Commit Languages Downloads

Project Detail

  • Language: Python > 3.6
  • Framework: Django > 3.1

Git Rules

S.A.G.E. team Git Rules Policy is available here:

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.

Diagram examples

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

$ python manage.py generate --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/

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

$ python manage.py generate --diagram sage_painless/tests/diagrams/product_diagram.json
  • run tests
$ python manage.py test sage_painless

Team

Sepehr Akbarzadeh Mehran Rahmanzadeh
Sepehr Akbarazadeh Maintainer Mehran Rahmanzadeh Maintainer

Goal

  • 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
  • multi Database
  • security config and check
  • seo
  • graphql
  • package manager support
Comments
  • Timer Decorator

    Timer Decorator

    https://github.com/sageteam-org/django-sage-painless/blob/1e8632982edb6f465bdf191eb5f92ae9b379c122/sage_painless/services/admin_generator.py#L77

    To have better practice convert time.time into a timer report decorator on your function

    wontfix 
    opened by sageteam-org 1
  • Args, Kwargs in Inheritance

    Args, Kwargs in Inheritance

    https://github.com/sageteam-org/django-sage-painless/blob/1e8632982edb6f465bdf191eb5f92ae9b379c122/sage_painless/services/admin_generator.py#L77

    To have better practice convert time.time into a timer report decorator on your function

    wontfix 
    opened by sageteam-org 0
  • It generates all code in one app

    It generates all code in one app

    there is no possibility to generate multiple apps with a single diagram. each diagram only contains the information of an app. It is better to be capable to generate multiple apps with a single diagram file.

    feature 
    opened by mehran-rahmanzadeh 0
  • It is not possible to restrict API methods

    It is not possible to restrict API methods

    when you generate a project including API, it generates all views with ModelViewSet that contains all methods. there is no capability to specify methods from the diagram file.

    class CategoryViewset(ModelViewSet):
        """
        Category Viewset
        Auto generated
        """
        serializer_class = CategorySerializer
        
        model_class = Category
    
        def get_queryset(self):
            """
            get queryset from cache
            """
            return self.model_class.get_all_from_cache()
    
        def get_object(self):
            """
            get object from cache
            """
            queryset = self.get_queryset()
            if len(queryset) == 0:
                raise Http404('Not Found')
            obj = queryset[0]
            return obj
    
    feature 
    opened by mehran-rahmanzadeh 0
  • Feature request: command to generate diagram from DB

    Feature request: command to generate diagram from DB

    The dumpdata command allows the generation of data that can be imported via fixtures. The structure is very similar, and could work as a starting point.

    Example in the Django docs for fixtures, and the inspectdb command.

    As an example, though, here’s what a fixture for a Person model might look like in JSON:

    [
      {
        "model": "myapp.person",
        "pk": 1,
        "fields": {
          "first_name": "John",
          "last_name": "Lennon"
        }
      },
      {
        "model": "myapp.person",
        "pk": 2,
        "fields": {
          "first_name": "Paul",
          "last_name": "McCartney"
        }
      }
    ]
    

    And here’s that same fixture as YAML:

    - model: myapp.person
      pk: 1
      fields:
        first_name: John
        last_name: Lennon
    - model: myapp.person
      pk: 2
      fields:
        first_name: Paul
        last_name: McCartney
    
    opened by dkdndes 1
  • [Snyk] Security upgrade nginx from 1.19.0-alpine to 1.20-alpine

    [Snyk] Security upgrade nginx from 1.19.0-alpine to 1.20-alpine

    Keeping your Docker base image up-to-date means you’ll benefit from security fixes in the latest version of your chosen image.

    Changes included in this PR

    • sage_painless/templates/Dockerfile.txt

    We recommend upgrading to nginx:1.20-alpine, as this image has only 0 known vulnerabilities. To do this, merge this pull request, then verify your application still works as expected.

    Some of the most important vulnerabilities in your base image include:

    | Severity | Priority Score / 1000 | Issue | Exploit Maturity | | :------: | :-------------------- | :---- | :--------------- | | critical severity | 500 | Out-of-bounds Read
    SNYK-ALPINE311-APKTOOLS-1534687 | No Known Exploit | | high severity | 400 | Integer Overflow or Wraparound
    SNYK-ALPINE311-OPENSSL-1075738 | No Known Exploit | | high severity | 400 | Integer Overflow or Wraparound
    SNYK-ALPINE311-OPENSSL-1075738 | No Known Exploit | | high severity | 400 | Improper Certificate Validation
    SNYK-ALPINE311-OPENSSL-1089242 | No Known Exploit | | high severity | 400 | Improper Certificate Validation
    SNYK-ALPINE311-OPENSSL-1089242 | No Known Exploit |


    Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open fix PRs.

    For more information: 🧐 View latest project report

    🛠 Adjust project settings

    opened by snyk-bot 0
  • [Snyk] Security upgrade nginx from 1.19.0-alpine to 1-alpine

    [Snyk] Security upgrade nginx from 1.19.0-alpine to 1-alpine

    Keeping your Docker base image up-to-date means you’ll benefit from security fixes in the latest version of your chosen image.

    Changes included in this PR

    • sage_painless/templates/Dockerfile.txt

    We recommend upgrading to nginx:1-alpine, as this image has only 0 known vulnerabilities. To do this, merge this pull request, then verify your application still works as expected.

    Some of the most important vulnerabilities in your base image include:

    | Severity | Priority Score / 1000 | Issue | Exploit Maturity | | :------: | :-------------------- | :---- | :--------------- | | critical severity | 500 | Out-of-bounds Read
    SNYK-ALPINE311-APKTOOLS-1534687 | No Known Exploit | | high severity | 400 | Integer Overflow or Wraparound
    SNYK-ALPINE311-OPENSSL-1075738 | No Known Exploit | | high severity | 400 | Integer Overflow or Wraparound
    SNYK-ALPINE311-OPENSSL-1075738 | No Known Exploit | | high severity | 400 | Improper Certificate Validation
    SNYK-ALPINE311-OPENSSL-1089242 | No Known Exploit | | high severity | 400 | Improper Certificate Validation
    SNYK-ALPINE311-OPENSSL-1089242 | No Known Exploit |


    Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open fix PRs.

    For more information: 🧐 View latest project report

    🛠 Adjust project settings

    opened by snyk-bot 0
  • Redundancy

    Redundancy

    https://github.com/sageteam-org/django-sage-painless/blob/1e8632982edb6f465bdf191eb5f92ae9b379c122/sage_painless/classes/field.py#L41

    Fix referenced redundancy options in code.

    wontfix 
    opened by sageteam-org 0
Releases(1.13.0)
  • 1.13.0(Aug 17, 2021)

    Added

    • Added package manager support
    • Added git commit generator
    • Added nginx config generator
    • Added nginx container in docker
    • Added uwsgi config generator
    • Added gunicorn config generator

    Fixed

    • Fixed gunicorn default config
    • Integrate gunicorn & uwsgi to docker generator
    • Create .env file generation in docker
    • Fixed some security bugs
    • Improved test generation
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Jul 23, 2021)

    Added

    • Added diagram format validator
    • Added README.md generator
    • Added multi app generation support
    • Added m2m field
    • Added API method support
    • Generate models in multiple files

    Fixed

    • Fixed reporter
    • Fixed management command
    • Fixed verbose name generation
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Jul 15, 2021)

    • Added specific import support (not using *)
    • Added multiple file generation (mixins.py, service.py, signals.py, ...)
    • Added validate required setting in management command
    • Added log user's answers for each app generation in docs
    Source code(tar.gz)
    Source code(zip)
  • 0.4(Jun 29, 2021)

Owner
sageteam
High-tech
sageteam
A starter template for building a backend with Django and django-rest-framework using docker with PostgreSQL as the primary DB.

Django-Rest-Template! This is a basic starter template for a backend project with Django as the server and PostgreSQL as the database. About the templ

Akshat Sharma 11 Dec 6, 2022
Django Fett is an incomplete code generator used on several projects

Django Fett Django Fett is an incomplete code generator used on several projects. This is an attempt to clean it up and make it public for consumption

Jeff Triplett 6 Dec 31, 2021
With Django Hijack, admins can log in and work on behalf of other users without having to know their credentials.

Django Hijack With Django Hijack, admins can log in and work on behalf of other users without having to know their credentials. Docs 3.x docs are avai

null 1.2k Jan 5, 2023
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 10k Dec 31, 2022
Django API without Django REST framework.

Django API without DRF This is a API project made with Django, and without Django REST framework. This project was done with: Python 3.9.8 Django 3.2.

Regis Santos 3 Jan 19, 2022
Django-static-site - A simple content site framework that harnesses the power of Django without the hassle

coltrane A simple content site framework that harnesses the power of Django with

Adam Hill 57 Dec 6, 2022
Intellicards-backend - A Django project bootstrapped with django-admin startproject mysite

Intellicards-backend - A Django project bootstrapped with django-admin startproject mysite

Fabrizio Torrico 2 Jan 13, 2022
Coltrane - A simple content site framework that harnesses the power of Django without the hassle.

coltrane A simple content site framework that harnesses the power of Django without the hassle. Features Can be a standalone static site or added to I

Adam Hill 58 Jan 2, 2023
Django-MySQL extends Django's built-in MySQL and MariaDB support their specific features not available on other databases.

Django-MySQL The dolphin-pony - proof that cute + cute = double cute. Django-MySQL extends Django's built-in MySQL and MariaDB support their specific

Adam Johnson 504 Jan 4, 2023
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 909 Dec 26, 2022
Full featured redis cache backend for Django.

Redis cache backend for Django This is a Jazzband project. By contributing you agree to abide by the Contributor Code of Conduct and follow the guidel

Jazzband 2.5k Jan 3, 2023
A Redis cache backend for django

Redis Django Cache Backend A Redis cache backend for Django Docs can be found at http://django-redis-cache.readthedocs.org/en/latest/. Changelog 3.0.0

Sean Bleier 1k Dec 15, 2022
this is a simple backend for instagram with python and django

simple_instagram_backend this is a simple backend for instagram with python and django it has simple realations and api in 4 diffrent apps: 1-users: a

null 2 Oct 20, 2021
Django backend of Helium's planner application

Helium Platform Project Prerequisites Python (>= 3.6) Pip (>= 9.0) MySQL (>= 5.7) Redis (>= 3.2) Getting Started The Platform is developed using Pytho

Helium Edu 17 Dec 14, 2022
Backend with Django .

BackendCode - Cookies Documentation: https://docs.djangoproject.com/fr/3.2/intro/ By @tcotidiane33 & @yaya Models Premium class Pack(models.Model): n

just to do it 1 Jan 28, 2022
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

talPor Solutions 703 Dec 22, 2022
An orgizational tool to keep track of tasks/projects and the time spent on them.

Django-Task-Manager Task Tracker using Python Django About The Project This project is an orgizational tool to keep track of tasks/projects and the ti

Nick Newton 1 Dec 21, 2021
:couple: Multi-user accounts for Django projects

django-organizations Summary Groups and multi-user account management Author Ben Lopatin (http://benlopatin.com / https://wellfire.co) Status Separate

Ben Lopatin 1.1k Jan 1, 2023
Duckiter will Automatically dockerize your Django projects.

Duckiter Duckiter will Automatically dockerize your Django projects. Requirements : - python version : python version 3.6 or upper version - OS :

soroush safari 23 Sep 16, 2021