Quickstart

Eager to get started? This page gives a good introduction to Flask-Kibble. It assumes you already have Flask-Kibble installed. If you do not, head over to the Installation section.

Lets assume we have these models to work with

from google.appengine.ext import ndb

class MyModel(ndb.Model):
    name = ndb.StringProperty()
    description = ndb.TextProperty()


class AnotherModel(ndb.Model):
    name = ndb.StringProperty()

A minimal Admin

Flask-Kibble provides flask_kibble.Kibble (A flask.Blueprint subclass ) to manage templates, url-routes, and permissions.

import flask
from flask.ext import kibble

app = flask.Flask(__name__)
admin = kibble.Kibble(
    'admin',
    __name__,
    kibble.Authenticator(),
    label='My Kibble Admin',
    static_url_path='/kibble/static'
)

app.register_blueprint(admin, url_prefix='/admin')

There’s a few extra parameters you’ll need to pass in:

If you run dev_appserver and head over to http://127.0.0.1:8080/admin/ you should see the start of your admin interface.

But this isn’t really helpful as we haven’t defined any views for our models.

A View or two

Each action (Create, Edit, List, etc) in your admin has its own View class. Lets create a few views for MyModel to allow creation of new instances, and a list view.

from flask.ext import kibble

class MyModelCreate(kibble.Create):
    model = models.MyModel

class MyModelList(kibble.List):
    model = models.MyModel

Now we need to register the views with our Kibble instance. You can either do this manually with register_view()

admin = kibble.Kibble('admin', __name__, kibble.Authenticator())

import views
admin.register_view(views.MyModelCreate)
admin.register_view(views.MyModelList)

or, have your admin autodiscovered with autodiscover()

admin = kibble.Kibble('admin', __name__, kibble.Authenticator())
admin.autodiscover(modules=['views'])

n.b. You must register your views before you register your blueprint.