The Admin

Ra Site

Ra Site is a custom admin site. It provide you the theme and other goodies aimed to make the dashboard more usable.

ModelAdmin Classes

A subclass of admin.ModelAdmin with various different options

  1. whole_changeform_validation
  2. View page

EntityAdmin offer two important hooks to manage little bit complicated flow

  1. it offer EntityAdmin.pre_save(self, form, formsets, change) It offers you a hook before saving the whole page to do any management you want. Like saving the total of the invoicelines in the Invoice.value field.
  2. whole_changeform_validation(self, request, form, formsets, change, **kwargs)() Where you’ll get a chance to validate the whole page forms and formsets

EntityAdmin

class ra.admin.admin.EntityAdmin(*args, **kwargs)[source]
changelist_view(request, extra_context=None)[source]

The ‘change list’ admin view for this model.

formfield_for_dbfield(db_field, request, **kwargs)[source]

Hook for specifying the form Field instance for a given database Field instance.

If kwargs are given, they’re passed to the form Field’s constructor.

get_actions(request)[source]

Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action.

get_changelist(request, **kwargs)[source]

Return the ChangeList class for use on the changelist page.

get_list_display(request)[source]

Return a sequence containing the fields to be displayed on the changelist.

has_view_permission(request, obj=None)[source]

Return True if the given request has permission to view the given Django model instance. The default implementation doesn’t examine the obj parameter.

If overridden by the user in subclasses, it should return True if the given request has permission to view the obj model instance. If obj is None, it should return True if the request has permission to view any object of the given type.

post_save(request, new_object, form, formsets, change)[source]

Hook for doing any final logic after saving :param form: :param formsets: :param change: :return:

pre_save(form, formsets, change)[source]

Hook for doing any final computation setting before saving :param form: :param formsets: :param change: :return:

reversion_register(model, **kwargs)[source]

Registers the model with reversion.

save_model(request, obj, form, change)[source]

Given a model instance save it to the database.

whole_changeform_validation(request, form, formsets, change, **kwargs)[source]

A Hook for validating the whole changeform :param form: the ModelAdmin Form :param formsets: inline formsets :param kwargs: extra kwargs :return: True for valid [default] False for Invalid

TransactionAdmin

class ra.admin.admin.TransactionAdmin(*args, **kwargs)[source]
formfield_for_dbfield(db_field, request, **kwargs)[source]

Hook for specifying the form Field instance for a given database Field instance.

If kwargs are given, they’re passed to the form Field’s constructor.

save_formset(request, form, formset, change)[source]

Given an inline formset save it to the database.

TransactionItemAdmin

class ra.admin.admin.TransactionItemAdmin(parent_model, admin_site)[source]
formfield_for_dbfield(db_field, request, **kwargs)[source]

Hook for specifying the form Field instance for a given database Field instance.

If kwargs are given, they’re passed to the form Field’s constructor.

get_permission_override_model(request, **kwargs)[source]

Return a string reprsentation of the model to look into its permissions, :param request: :param kwargs: :return:

get_ra_permission_codename(action, model_name)[source]

Returns the codename of the permission for the specified action.

has_add_permission(request, obj=None)[source]

Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.

has_change_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.

has_delete_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.

view_on_site = False

To simplify complex forms with inline , making inline permission reflect base form permission permission_override_model can be True, False , str Or ModelBase