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.1.tar.gz (19.0 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.1-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_generate-0.1.1.tar.gz
  • Upload date:
  • Size: 19.0 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.1.tar.gz
Algorithm Hash digest
SHA256 6ac1c2f7e7fad6c01bd20d6707293ef224a7d4aaa7b0c0d9aa5f7361f59ce433
MD5 388f975066c4c75e952cd2f0c0f9ed3b
BLAKE2b-256 2386cfbb809727be4c859c4d7bf148d4fba5887c9b3c37bc84af5560b2a80244

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_generate-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 32.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9e2a6a04f736dafaa5fb032a9a95217dc8bc17249752e617567bd73dafd4fae
MD5 e79ac65f6403ae910c37d1edb92a840d
BLAKE2b-256 f19952359f6f69815036bd5c38a142312a61c27e1d9e0b4596eb6c75b1928f71

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