Skip to main content

Flask-Generate

Flask-Generate is a Flask extension that allows you to create web applications faster by creating models, routes and forms from console. It also generates scaffolds with CRUD operations.

Usage

Installation

pip install Flask-Generate

Generate a new Flask app

With Flask-Generate you can start a new project that contains base code to start working with

flask-generate app <my-app-name>

The flask-generate app command comes with two optional flags.

  • --type: Indicates the app structure
    • options: MVC and Blueprint
    • default: mvc
  • --orm: The ORM option to generate models based on it
    • options: SQLAlchemy and Peewee
    • default: SQLAlchemy

Example:

flask-generate app <app-name> --type blueprint --orm sqlalchemy

Generators

Once you have the Flask-Generate extension installed, you have access to the generate commands group and start working with models, forms and blueprints.

Blueprint

Blueprint generation will depend on the chosen app structure, if the chosen structure it's MVC the new blueprint will be saved on the blueprints folder as a Python module, else, the blueprint will be a Python package, similar to a Django app.

Arguments:

  • name: Generates a Python file or package with this param

Example:

flask generate blueprint posts

Dest for mvc-like apps: my-app/blueprints/posts.py Dest for blueprint-like apps: my-app/posts

Models

Flask-Generate takes the GENERATE_ORM constant from settings to create models depending on the chosen ORM

Arguments:

  • name: The model name, must be in PascalCase
  • fields: List of model fields, must be declared as follows; field_name:type
  • -d | --dest: File or Blueprint name where the model will be saved.

Example:

flask generate model Post title:str body:text --dest posts

Generated models should be saved on models/posts.py for mvc-like apps and posts/models.py for blueprint-like apps

Forms

Same as model command it takes the same parameters, but generates a form using the WTForms library.

Arguments:

  • name: The model name, must be in PascalCase
  • fields: List of model fields, must be declared as follows; field_name:type
  • -d | --dest: File or Blueprint name where the model will be saved

Example:

flask generate form Post title:str body:text --dest posts

Generated forms should be saved on forms/posts.py for mvc-like apps and posts/forms.py for blueprint-like apps.

Scaffolds

Flask-Generate can create a fully functional scaffold with CRUD operations; the scaffold generates all the necessary code to start faster (model, forms, routes and templates)

Arguments:

  • name: This will be used to generate the related scaffolding files or a full package
  • model: Model name that generates a SQLAlchemy/Peewee class to work with
  • fields: Model fields that also will be used to generate the form

Example:

flask generate scaffold posts Post title:str body:text

Metadata

Release files for Flask-Generate 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Generate 0.2.0
File Size Uploaded
flask_generate-0.2.0.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-Generate 0.2.0
File Interpreter ABI Platform
flask_generate-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.5 kB

Release files / flask_generate-0.2.0.tar.gz

Download URL flask_generate-0.2.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9dd7638e9e5b65b806c8dbed3ceebfa9e54578bc32b5cb592a3c04a969cbc0eb
BLAKE2b-256 checksum
How to use checksums
ab35433f98885ceee7c9a1624c72b4bf54f1c41500162372ac18eff1a6abac01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.14.2 Windows/11

Release files / flask_generate-0.2.0-py3-none-any.whl

Download URL flask_generate-0.2.0-py3-none-any.whl
Size 32.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1583a2ad905ee0c67bd457fa4b7ffacd178f011dcf73592b2e72b95b0461b743
BLAKE2b-256 checksum
How to use checksums
57e33be68b8aed095c5b99d1bfec1040cfe449f43abad713b4486f978778ba01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.14.2 Windows/11

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page