Skip to content

Instantly share code, notes, and snippets.

View hansthen's full-sized avatar

Hans Then hansthen

  • The Netherlands
View GitHub Profile
@hansthen
hansthen / filter select field.py
Last active July 6, 2023 20:47 — forked from mrjoes/test.py
How to customize options in QuerySelectField.High level idea:1. Hook `create_form` to change options when creating model and `edit_form` when editing model2. Provide different `query_factory` for the field3. Do filtering/population logic in the _get_parent_listAlternatively:1. Can hook `scaffold_form` and change `form.parent.kwargs['query_factor…
from flask import Flask, request, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.admin.contrib import sqlamodel
from flask.ext import admin
# Create application
app = Flask(__name__)
# Create dummy secrey key so we can use sessions