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 simple demonstration of how a django-based website can be set up for local development with microk8s

Django with MicroK8s Start Building Your Project This project provides a Django web app running as a single node Kubernetes cluster in microk8s. It is

Noah Jacobson 19 Oct 22, 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 application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

2.6k Dec 26, 2022
Cached file system for online resources in Python

Minato Cache & file system for online resources in Python Features Minato enables you to: Download & cache online recsources minato supports the follo

Yasuhiro Yamaguchi 10 Jan 04, 2023
pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-dev 1.1k Dec 14, 2022
GameStop clone with Django

GameStop clone with Django This is my side project with GameStop clone Author: HackerApe GitHub Profile: View Profile LinkedIn Profile: View Profile

Dmitriy Shin 2 Dec 26, 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

1.2k Jan 05, 2023
A simple porfolio with Django, Bootstrap and Sqlite3

Django Portofolio Example this is a basic portfolio in dark mode Installation git clone https://github.com/FaztWeb/django-portfolio-simple.git cd djan

Fazt Web 16 Sep 26, 2022
Basic Form Web Development using Python, Django and CSS

thebookrain Basic Form Web Development using Python, Django and CSS This is a basic project that contains two forms - borrow and donate. The form data

Ananya Dhulipala 1 Nov 27, 2021
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-gmailapi-json-backend - Email backend for Django which sends email via the Gmail API through a JSON credential

django-gmailapi-json-backend Email backend for Django which sends email via the

Innove 1 Sep 09, 2022
Logan is a toolkit for building standalone Django applications

Logan Logan is a toolkit for running standalone Django applications. It provides you with tools to create a CLI runner, manage settings, and the abili

David Cramer 206 Jan 03, 2023
Website desenvolvido em Django para gerenciamento e upload de arquivos (.pdf).

Website para Gerenciamento de Arquivos Features Esta é uma aplicação full stack web construída para desenvolver habilidades com o framework Django. O

Alinne Grazielle 8 Sep 22, 2022
Code coverage measurement for Python

Coverage.py Code coverage testing for Python. Coverage.py measures code coverage, typically during test execution. It uses the code analysis tools and

Ned Batchelder 2.3k Jan 05, 2023
Modular search for Django

Haystack Author: Daniel Lindsley Date: 2013/07/28 Haystack provides modular search for Django. It features a unified, familiar API that allows you to

Haystack Search 3.4k Jan 08, 2023
Use minify-html, the extremely fast HTML + JS + CSS minifier, with Django.

django-minify-html Use minify-html, the extremely fast HTML + JS + CSS minifier, with Django. Requirements Python 3.8 to 3.10 supported. Django 2.2 to

Adam Johnson 60 Dec 28, 2022
A Django application that provides country choices for use with forms, flag icons static files, and a country field for models.

Django Countries A Django application that provides country choices for use with forms, flag icons static files, and a country field for models. Insta

Chris Beaven 1.2k Jan 07, 2023
Django And React Notes App

Django & React Notes App Cloning the repository -- Clone the repository using the command below : git clone https://github.com/divanov11/Django-React

Dennis Ivy 136 Dec 27, 2022
Django Starter is a simple Skeleton to start with a Django project.

Django Starter Template Description Django Starter is a simple Skeleton to start

Numan Ibn Mazid 1 Jan 10, 2022
Thumbnails for Django

Thumbnails for Django. Features at a glance Support for Django 2.2, 3.0 and 3.1 following the Django supported versions policy Python 3 support Storag

Jazzband 1.6k Jan 03, 2023