Clone wiki

web2py_crud / Home


This is an experimental plugin for web2py that provides CRUD operations via AJAX. The plugin provides 3 components: CRUD, List, and List/Details. CRUD by itself generates an AJAX version of CRUD operations, while the two list components provide a way to list records. CRUD is integrated into the lists, but can be used by itself, as it creates global JavaScript functions that can be called manually for CRUD operations if you prefer using your own listing method.

Why Another CRUD

The core of web2py includes a nice CRUD module that makes scaffolding an application really quick and easy. It is also customizable enough to use in production. This plugin adopts the same principal functionality, but does so using AJAX calls. This reduces the number of page loads required in order to perform CRUD operations.


  • jQuery UI included in your layout.
  • For now, each table you want to list must specify a format= argument in define_table() (see web2py documentation on this parameter), otherwise an error ticket is generated.

What Does It Look Like

Simple List

Simple List

This is just a simple list of records. Optionally, you can allow the items in this list to be reorderable by the user.

Create/Update Dialog

Create/Update Dialog

When using plugin_crud manually, or when using the simple list pictured above, a jQuery UI Dialog is used to display the generated form.

List/Details View

List/Details View

For more complex applications, the simple list can be transformed into a list/details view where the create/update form is shown to the right of the list, instead of in a dialog. This generally makes for a better user experience, rather than having dialog boxes pop up all over the place. The list here can also be reordered, if needed.

Example Usage

This code is very new and was just uploaded to BitBucket, so the documentation is sparse at the moment. This will change soon. Until then, review the example before for basic usage of the plugin.


This is just an example model:

# jQuery UI is required, so make sure these are loaded.
response.files.append(URL('static', 'css/mac-theme/jquery-ui-1.8.13.custom.css'))
response.files.append(URL('static', 'js/jquery-ui-1.8.10.js'))

product_classes = {
    1: 'Class 1',
    2: 'Class 2',
    3: 'Class 3'

    Field('product_number', length=20),
    Field('name', length=128),
    Field('description', 'text'),
    Field('active', 'boolean'),
    Field('product_class', 'integer', requires=IS_IN_SET(product_classes, zero=None)),
    format = lambda r:

Notice the format argument at the end of the model. That is required in order to use the list options, so that the list knows how to represent each record to the user.


def index():
    crud = plugin_crud('product')
    l = crud_list_details('product', crud=crud)
    return dict(list=l)

That's it! The first argument tells the plugin what table to generate CRUD operations for. The plugin is easy to use and is very flexible. See the Other Examples section below for more information.

Other Examples

  • CRUD Options - A detailed explanation of how to use plugin_crud() to create CRUD instances.
  • More examples for using crud_list() and crud_list_details() coming soon!

Have fun and please send your comments, questions, and patches!