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
django-idom allows Django to integrate with IDOM

django-idom allows Django to integrate with IDOM, a package inspired by ReactJS for creating responsive web interfaces in pure Python.

113 Jan 04, 2023
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
A fresh approach to autocomplete implementations, specially for Django. Status: v3 stable, 2.x.x stable, 1.x.x deprecated. Please DO regularely ping us with your link at #yourlabs IRC channel

Features Python 2.7, 3.4, Django 2.0+ support (Django 1.11 (LTS), is supported until django-autocomplete-light-3.2.10), Django (multiple) choice suppo

YourLabs 1.7k Jan 01, 2023
Source code for Django for Beginners 3.2

The official source code for https://djangoforbeginners.com/. Available as an ebook or in Paperback. If you have the 3.1 version, please refer to this

William Vincent 10 Jan 03, 2023
Automatically deletes old file for FileField and ImageField. It also deletes files on models instance deletion.

Django Cleanup Features The django-cleanup app automatically deletes files for FileField, ImageField and subclasses. When a FileField's value is chang

Ilya Shalyapin 838 Dec 30, 2022
A Django Demo Project of Students Management System

Django_StudentMS A Django Demo Project of Students Management System. From NWPU Seddon for DB Class Pre. Seddon simplify the code in 2021/10/17. Hope

2 Dec 08, 2021
Django + AWS Elastic Transcoder

Django Elastic Transcoder django-elastic-transcoder is an Django app, let you integrate AWS Elastic Transcoder in Django easily. What is provided in t

StreetVoice 66 Dec 14, 2022
Simple application TodoList django with ReactJS

Django & React Django We basically follow the Django REST framework quickstart guide here. Create backend folder with a virtual Python environment: mk

Flavien HUGS 2 Aug 07, 2022
A collection of models, views, middlewares, and forms to help secure a Django project.

Django-Security This package offers a number of models, views, middlewares and forms to facilitate security hardening of Django applications. Full doc

SD Elements 258 Jan 03, 2023
A small and lightweight imageboard written with Django

Yuu A small and lightweight imageboard written with Django. What are the requirements? Python 3.7.x PostgreSQL 14.x Redis 5.x FFmpeg 4.x Why? I don't

mint.lgbt 1 Oct 30, 2021
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django 🚀 Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 09, 2022
Let AngularJS play well with Django

django-angular Let Django play well with AngularJS What does it offer? Add AngularJS directives to Django Forms. This allows to handle client side for

Jacob Rief 1.2k Dec 27, 2022
Notes-Django: an advanced project to save notes in Django. where users are able to Create, Read, Update and Delete their notes.

An advanced software to keep you notes. It allows users to perform CRUD operations on theirs Notes. Was implemented Authorization and Authentication

Edilson Pateguana 1 Feb 05, 2022
PostgreSQL with Docker + Portainer + pgAdmin + Django local

django-postgresql-docker Running PostgreSQL with Docker + Portainer + pgAdmin + Django local for development. This project was done with: Python 3.9.8

Regis Santos 4 Jun 12, 2022
Yet another Django audit log app, hopefully the simplest one.

django-easy-audit Yet another Django audit log app, hopefully the easiest one. This app allows you to keep track of every action taken by your users.

Natán 510 Jan 02, 2023
Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Oscar Y Chen 68 Jan 07, 2023
Example project demonstrating using Django’s test runner with Coverage.py

Example project demonstrating using Django’s test runner with Coverage.py Set up with: python -m venv --prompt . venv source venv/bin/activate python

Adam Johnson 5 Nov 29, 2021
Django Girls Tutorial Workshop

Django Girls Tutorial Workshop A log of activities during the workshop. this is an H2 git remote add origin https://github.com/ahuimanu/django_girls_t

Jeffry Babb 1 Oct 27, 2021
🌟 A social media made with Django and Python and Bulma. 🎉

Vitary A simple social media made with Django Installation 🛠️ Get the source code 💻 git clone https://github.com/foxy4096/Vitary.git Go the the dir

Aditya Priyadarshi 15 Aug 30, 2022
Easily share data across your company via SQL queries. From Grove Collab.

SQL Explorer SQL Explorer aims to make the flow of data between people fast, simple, and confusion-free. It is a Django-based application that you can

Grove Collaborative 2.1k Dec 30, 2022