Flask-Model-Management
- This is a Flask extension for managing Flask-SQLAlchemy models.
- This extension allows the user to perform CRUD (create, read, update, delete) operations on the models registered using the UI
The frontend is built using:
- Bootstrap4 (https://getbootstrap.com/)
- JQuery (https://jquery.com/)
- Datatables (https://datatables.net/)
- Feather Icons (https://feathericons.com/)
- This bootstrap theme (https://getbootstrap.com/docs/4.5/examples/dashboard/)
- Flatpickr for date(time) fields (https://flatpickr.js.org/)
- Jinja2
NB: all the above JS & CSS are bundled into this package currently
The backend is built using:
- Flask-SQLAlchemy & SQLAlchemy
- Flask-WTF & WTForms
Status: In Alpha Development
BE WARNED: INSTALLING CRUD APPLICATIONS INTO PRODUCTION SERVERS ALLOWS USERS TO PERFORM POTENTIALLY IRREVERSIBLE DATA OPERATIONS
Install
pip install:
pip install flask_model_management
Use
- an example of how to use without app factory might look something like:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_model_management import ModelManager
app = Flask(__name__)
# from flask_sqlalchemy docs
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
model_manager = ModelManager(app, db)
# showing model declaration for the example
class User(db.Model):
__tablename__ = "user"
id = Column(Integer, primary_key=True)
username = Column(String)
model_manager.register_model(User)
- with app factory:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_model_management import ModelManager
db = SQLAlchemy()
model_manager = ModelManager()
# showing model declaration for the example
class User(db.Model):
__tablename__ = "user"
id = Column(Integer, primary_key=True)
username = Column(String, nullable=False)
def create_app():
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db.init_app(app)
model_manager.init_app(app, db)
model_manager.register_model(User, nullable=False)
UI Examples
-
Home page
-
Table page
-
Create (single entry) page
-
Read (bulk entries) page
-
Update (single) page
-
Update (bulk) page
-
Delete (single) page
-
Delete (bulk) page
How it works
frontend perspective
- Once you plug-in this extension then at: /model-management/ you will find the home dashboard
- You can browse around the pages and perform CRUD operations on your models
backend perspective
- A blueprint is added to your app called
model_managementwith the url prefix/model-management - 4 url routes are added to this blueprint:
- A home page at:
/ - A table page at:
/<tablename> - An operation page at:
/<tablename>/<operation>- Operations limited to: create, read, update or delete
- An operation API at:
/api/<tablename>- CRUD operations are mapped to HTTP methods:
- POST = create
- GET = read
- PUT = update
- DELETE = delete
- CRUD operations are mapped to HTTP methods:
- A home page at:
- The data from the frontend forms are then sent via ajax request to the operation API with the required data and HTTP method
- WARNING: this library will therefore wrap your Flask-SQLAlchemy models with an API endpoint
- There are 2 'protocols': single & bulk
- single is for CRUD applied to one entry
- always applied to: CREATE
- sometimes applied to: UPDATE, DELETE
- bulk is for CRUD applied to multiple entries (and is default in all but CREATE)
- always applied to: READ
- sometimes (default) applied to: UPDATE, DELETE
- single is for CRUD applied to one entry
Todo
- re-add decorators to models
- excluded columns
- excluded operations
Metadata
Release files for Flask-Model-Management 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| Flask-Model-Management-0.1.0.tar.gz | 158.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Flask_Model_Management-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 323.0 kB
Release files / Flask-Model-Management-0.1.0.tar.gz
| Download URL | Flask-Model-Management-0.1.0.tar.gz |
|---|---|
| Size | 158.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9de3ab0cd337cc89579736b7b1bcd313bd624c932d4e6a8d15aa849ec54d1ee9
|
|
BLAKE2b-256 checksum How to use checksums |
53450522b845ee71b7882a5ac84e9aae9f4726c2682cdc6bc97c294f94398ea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.4
|
Release files / Flask_Model_Management-0.1.0-py3-none-any.whl
| Download URL | Flask_Model_Management-0.1.0-py3-none-any.whl |
|---|---|
| Size | 164.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b732cf027dcd10d1bb9d5e9bc1e77ed666292162951d341cb306ca5192d96bc6
|
|
BLAKE2b-256 checksum How to use checksums |
0484bf623f8dd3e4184965b5c3d4d8edc6f3bf7b61d4854b2a72e1ec6deb0e9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.4
|
Security for Flask-Model-Management 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.