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 CRUD REST API Generator

Django CRUD REST API Generator This is a simple tool that generates a Django REST API with the given models. Specs: Authentication, DRF generic views,

Mehmet Alp Sümer 57 Nov 24, 2022
A package to handle images in django

Django Image Tools Django Image Tools is a small app that will allow you to manage your project's images without worrying much about image sizes, how

The Bonsai Studio 42 Jun 02, 2022
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 07, 2023
📝 Sticky Notes in Django admin

django-admin-sticky-notes Share notes between superusers. Installation Install via pip: pip install django_admin_sticky_notes Put django_admin_sticky_

Dariusz Choruży 7 Oct 06, 2021
Sistema de tratamento e análise de grandes volumes de dados através de técnicas de Data Science

Sistema de tratamento e análise de grandes volumes de dados através de técnicas de data science Todos os scripts, gráficos e relatórios de todas as at

Arthur Quintanilha Neto 1 Sep 05, 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 06, 2022
Django Query Capture can check the query situation at a glance, notice slow queries, and notice where N+1 occurs.

django-query-capture Overview Django Query Capture can check the query situation at a glance, notice slow queries, and notice where N+1 occurs. Some r

GilYoung Song 80 Nov 22, 2022
Opinionated boilerplate for starting a Django project together with React front-end library and TailwindCSS CSS framework.

Opinionated boilerplate for starting a Django project together with React front-end library and TailwindCSS CSS framework.

João Vítor Carli 10 Jan 08, 2023
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
An API was build with Django to store and retrieve information about various musical instruments.

The project is meant to be a starting point, an experimentation or a basic example of a way to develop an API with Django. It is an exercise on using Django and various python technologies and design

Kostas Ziovas 2 Dec 25, 2021
Twitter Bootstrap for Django Form

Django bootstrap form Twitter Bootstrap for Django Form. A simple Django template tag to work with Bootstrap Installation Install django-bootstrap-for

tzangms 557 Oct 19, 2022
A Django backed for PostgreSQL using Psycopg 3

A Django backend for PostgreSQL using Psycopg 2 The backend passes the entire Django test suite, but it needs a few modifications to Django and to i

Daniele Varrazzo 42 Dec 16, 2022
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 + 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
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
Visual DSL framework for django

Preface Processes change more often than technic. Domain Rules are situational and may differ from customer to customer. With diverse code and frequen

Dmitry Kuksinsky 165 Jan 08, 2023
Yummy Django API, it's the exclusive API used for the e-yummy-ke vue web app

Yummy Django API, it's the exclusive API used for the e-yummy-ke vue web app

Am.Chris_KE 1 Feb 14, 2022
A helper for organizing Django project settings by relying on well established programming patterns.

django-configurations django-configurations eases Django project configuration by relying on the composability of Python classes. It extends the notio

Jazzband 953 Dec 29, 2022
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
A Django web application that allows you to be in the loop about everything happening in your neighborhood.

A Django web application that allows you to be in the loop about everything happening in your neighborhood. From contact information of different handyman to meeting announcements or even alerts.

Kennedy Ngugi Mwaura 3 Dec 11, 2022