Skip to main content

A Flask extension to generate CRUD routes based on models.

Project description

Flask Crud Generator

Allow you to generate CRUD routes based on your models in a Flask application

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_crud_generator import CRUDGenerator

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)
crud = CRUDGenerator(app, db)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    email = db.Column(db.String(120), unique=True)

    def to_dict(self):
        return {'id': self.id, 'name': self.name, 'email': self.email}

class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))

    def to_dict(self):
        return {'id': self.id, 'name': self.name}

crud.generate_routes(User)
products = Blueprint("products", __name__)
# you can also pass a blueprint to a crud generator
crud.generate_routes(Product, products, 'products')

with app.app_context():
    db.create_all()

if __name__ == '__main__':
    app.run(debug=True)

Then go to locahost:5000/user or locahost:5000/product

Todos :

  • Support models relationships
  • Support ORM other than SQLAlchemy
  • Generate HTML views with basics forms
  • Custom data validations
  • Choose which CRUD operations for which model

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_crud_generator-0.2.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

flask_crud_generator-0.2.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file flask_crud_generator-0.2.0.tar.gz.

File metadata

  • Download URL: flask_crud_generator-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for flask_crud_generator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fa88da68e0719961788973bb4ab0d0f6bc9bfc91739023d6b569729774fdd09b
MD5 3b77e1b59613a1ba79af802be29b5712
BLAKE2b-256 7e84cfa43ffeb54fd91a181ee7733e1daa828899e890afdc18dac3631be81b64

See more details on using hashes here.

File details

Details for the file flask_crud_generator-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_crud_generator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dae0c5cdf53d2a6e138e908dbc9d7937039e66acaafa9d4e9d4b836bb8c3c1d0
MD5 e3fad188541bb697425113bf75e8abc3
BLAKE2b-256 05d682e3d0f6aa797d1a0748ed61616656adfcdd6a07f19234f1b84b95610d03

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page