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
DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

Mokrani Yacine 2 Sep 28, 2022
A reusable Django model field for storing ad-hoc JSON data

jsonfield jsonfield is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database.

Ryan P Kilby 1.1k Jan 03, 2023
Dashboad Full Stack utilizando o Django.

Dashboard FullStack completa Projeto finalizado | Informações Cadastro de cliente Menu interatico mostrando quantidade de pessoas bloqueadas, liberada

Lucas Silva 1 Dec 15, 2021
Indonesia's negative news detection using gaussian naive bayes with Django+Scikir Learn

Introduction Indonesia's negative news detection using gaussian naive bayes build with Django and Scikit Learn. There is also any features, are: Input

Harifzi Ham 1 Dec 30, 2021
Django-discord-bot - Framework for creating Discord bots using Django

django-discord-bot Framework for creating Discord bots using Django Uses ASGI fo

Jamie Bliss 1 Mar 04, 2022
A Student/ School management application built using Django and Python.

Student Management An awesome student management app built using Django.! Explore the docs » View Demo · Report Bug · Request Feature Table of Content

Nishant Sethi 1 Feb 10, 2022
💨 Fast, Async-ready, Openapi, type hints based framework for building APIs

Fast to learn, fast to code, fast to run Django Ninja - Fast Django REST Framework Django Ninja is a web framework for building APIs with Django and P

Vitaliy Kucheryaviy 3.8k Jan 01, 2023
This is a template tag project for django to calculate in templates , enjoy it

Calculator-Template-Django this is a template tag project for django to calculate in templates , enjoy it Get Started : 1 - Download Source Code 2 - M

1 Feb 01, 2022
A calendaring app for Django. It is now stable, Please feel free to use it now. Active development has been taken over by bartekgorny.

Django-schedule A calendaring/scheduling application, featuring: one-time and recurring events calendar exceptions (occurrences changed or cancelled)

Tony Hauber 814 Dec 26, 2022
Django/Jinja template indenter

DjHTML A pure-Python Django/Jinja template indenter without dependencies. DjHTML is a fully automatic template indenter that works with mixed HTML/CSS

Return to the Source 378 Jan 01, 2023
Book search Django web project that uses requests python library and openlibrary API.

Book Search API Developer: Vladimir Vojtenko Book search Django web project that uses requests python library and openlibrary API. #requests #openlibr

1 Dec 08, 2021
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App 💛 We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
This is a personal django website for forum posts

Django Web Forum This is a personal django website for forum posts It includes login, registration and forum posts with date time. Tech / Framework us

5 May 12, 2022
Built from scratch to replicate some of the Django admin functionality and add some more, to serve as an introspective interface for Django and Mongo.

django-mongonaut Info: An introspective interface for Django and MongoDB. Version: 0.2.21 Maintainer: Jazzband (jazzband.co) This Project is Being Mov

Jazzband 238 Dec 26, 2022
Django admin CKEditor integration.

Django CKEditor NOTICE: django-ckeditor 5 has backward incompatible code moves against 4.5.1. File upload support has been moved to ckeditor_uploader.

2.2k Dec 31, 2022
Ugly single sign-on for django projects only

django-usso Ugly single sign-on for django projects only. Do you have many django apps with different users? Do you want to use only one of those apps

Erwin Feser 1 Mar 01, 2022
An extremely fast JavaScript and CSS bundler and minifier

Website | Getting started | Documentation | Plugins | FAQ Why? Our current build tools for the web are 10-100x slower than they could be: The main goa

Evan Wallace 34.2k Jan 04, 2023
A ToDO Rest API using Django, PostgreSQL and Docker

This Rest API uses PostgreSQL, Docker and Django to implements a ToDo application.

Brenno Lima dos Santos 2 Jan 05, 2022
Django channels basic chat

Django channels basic chat

Dennis Ivy 41 Dec 24, 2022
An app that allows you to add recipes from the dashboard made using DJango, JQuery, JScript and HTMl.

An app that allows you to add recipes from the dashboard. Then visitors filter based on different categories also each ingredient has a unique page with their related recipes.

Pablo Sagredo 1 Jan 31, 2022