Skip to main content

Scaffolding generator for the Flask framework.

Project description

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

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_generate-0.1.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_generate-0.1.0-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file flask_generate-0.1.0.tar.gz.

File metadata

  • Download URL: flask_generate-0.1.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.2 Windows/11

File hashes

Hashes for flask_generate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6be1a2314feb2b9f958e1ee9dbd2b0031b41c5970bbec0f7b4b1db9e210b2d9b
MD5 c49174a449241fe296c71ab550aebb55
BLAKE2b-256 35e500a6035401baf0e410f038ddc81ea39800e99ba4d8af6932f54a60ab376b

See more details on using hashes here.

File details

Details for the file flask_generate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flask_generate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.2 Windows/11

File hashes

Hashes for flask_generate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7454bd932797090934b63834d5716a666db18764da065c6520e7f88f7cdcb4a
MD5 e51109536a2fb7d8c4a9a05ed77c86a4
BLAKE2b-256 82686af140b324c4de8eda71df9d43803d0842cbfa705aad209e69f4ee428d63

See more details on using hashes here.

Supported by

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