Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/flask-admin@1.6.x
tile.json

tessl/pypi-flask-admin

tessl install tessl/pypi-flask-admin@1.6.0

Simple and extensible admin interface framework for Flask

Agent Success

Agent success rate when using this tile

86%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.3x

Baseline

Agent success rate without this tile

66%

task.mdevals/scenario-8/

Product Catalog Admin Form

Build an admin interface for a product catalog with customized form generation and layout.

Requirements

Create a Flask application with an admin interface for managing products. The application should:

  1. Define a Product model with these fields:

    • name (string, required)
    • sku (string, required, unique)
    • description (text)
    • price (decimal)
    • stock_quantity (integer)
    • category (string)
    • is_active (boolean, default True)
    • created_at (datetime)
  2. Create an admin view for the Product model with the following customizations:

    • Exclude the created_at field from the create form
    • Make the description field use a textarea widget with 5 rows
    • Add a custom label "Product Name" for the name field
    • Add a description "SKU must be unique" for the sku field
    • Add validation to ensure price is greater than 0
    • Add validation to ensure stock_quantity is not negative
  3. Organize the form layout into sections:

    • A "Basic Information" section containing: name, sku, category
    • A "Details" section containing: description, price, stock_quantity
    • An "Status" section containing: is_active

Capabilities

Form generation from model

  • The form should be automatically generated from the Product model @test
  • The form should include all model fields except those explicitly excluded @test

Field customization

  • The description field should render as a textarea with 5 rows @test
  • The name field should display the label "Product Name" @test
  • The sku field should show the description "SKU must be unique" @test

Form validation

  • Submitting a form with price of -10 should fail validation @test
  • Submitting a form with stock_quantity of -5 should fail validation @test
  • Submitting a form with valid data should succeed @test

Form layout organization

  • The form should display fields grouped into three sections: "Basic Information", "Details", and "Status" @test

Implementation

@generates

API

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView

# Create Flask app and database instance
app = Flask(__name__)
db = SQLAlchemy(app)

# Product model
class Product(db.Model):
    """Product model with catalog information"""
    pass

# Custom ProductAdmin view
class ProductAdmin(ModelView):
    """Admin view for Product model with form customizations"""
    pass

# Initialize admin
admin = Admin(app, name='Product Catalog', template_mode='bootstrap4')
admin.add_view(ProductAdmin(Product, db.session))

Dependencies { .dependencies }

Flask-Admin { .dependency }

Provides admin interface framework with form generation and customization capabilities.

Flask-SQLAlchemy { .dependency }

Provides SQLAlchemy integration for Flask.

WTForms { .dependency }

Provides form validation support (used by Flask-Admin).