EntityAdmin

EntityAdmin is a specialization of ObjectAdmin, to be used for classes that are mapped by Sqlalchemy. EntityAdmin will use introspection to determine field types and assign according delegates and editors.

class camelot.admin.entity_admin.EntityAdmin(app_admin, entity)[source]

Admin class specific for classes that are mapped by sqlalchemy. This allows for much more introspection than the standard camelot.admin.object_admin.ObjectAdmin.

It has additional class attributes that customise its behaviour.

Basic

list_action

The camelot.admin.action.Action that will be triggered when the user selects an item in a list of objects. This defaults to camelot.admin.action.list_action.OpenFormView, which opens a form for the current object.

Filtering

list_filter

A list of fields that should be used to generate filters for in the table view. If the field named is a one2many, many2one or many2many field, the field name should be followed by a field name of the related entity

class Project(Entity):
    oranization = OneToMany('Organization')
    name = Field(Unicode(50))

  class Admin(EntityAdmin):
      list_display = ['organization']
      list_filter = ['organization.name']
../_images/group_box_filter.png

Copying

copy_deep

A dictionary of fields that will be deep copied when the user presses the copy button. This is usefull for OneToMany fields. The key in the dictionary should be the name of the field, and the value is a new dictionary that can contain other fields that need to be copied:

copy_deep = {'addresses':{}}
copy_exclude

A list of fields that should not be copied when the user presses the copy button:

copy_exclude = ['name']

The fields that form the primary key of the object will be excluded by default.

Searching

A list of fields that should be searched when the user enters something in the search box in the table view. By default all fields are searched for which Camelot can do a conversion of the entered string to the datatype of the underlying column.

For use with one2many, many2one or many2many fields, the same rules as for the list_filter attribute apply

search_all_fields

Defaults to True, meaning that by default all searchable fields should be searched. If this is set to False, one should explicitely set the list_search attribute to enable search.

A list of fields that will be searchable through the expanded search. When set to None, all the fields in list_display will be searchable. Use this attribute to limit the number of search widgets. Defaults to None.

Previous topic

ObjectAdmin

Next topic

Field Attributes

This Page


Comments
blog comments powered by Disqus