Contents

Models

class admin_kit.models.BaseField(kit_config=None, ajax_source=None, ajax_target=None, ajax_subscribe=False, *args, **kwargs)[source]

The Base model field of Admin-Kit models. This inherits Django’s models.Field class.

deconstruct()[source]

Deconstructs the field to a tuple of 4 elements. This is used to recreate the same object.

formfield(form_class, choices_form_class=None, **kwargs)[source]

Returns the form object to be used for rendering.

from_db_value(value, expression, connection, context)[source]

Returns value from the database. inherited models should override this

validate(value, model_instance)[source]

To validate the value of a model instance. Inherited models should override this

value_to_string(obj)[source]

Converts the value of the object to a string

class admin_kit.models.MultiSelectField(seperator=', ', *args, **kwargs)[source]

The Multiselect model field of Admin-Kit, which allows users to create multi select ajax fields.

Fields

class admin_kit.fields.BaseField(kit_config=None, ajax_source=None, ajax_target=None, ajax_subscribe=None, *args, **kwargs)[source]

The Base Field for form fields

widget_attrs(widget)[source]

This will add data-kit-config attibute to the widget

class admin_kit.fields.MultiSelectField(seperator=', ', choices=(), *args, **kwargs)[source]

This field is used to create MultiSelect Form fields.

widget

alias of SelectMultipleWidget

Widgets

class admin_kit.widgets.SelectMultipleWidget(*args, **kwargs)[source]

MultiSelect Widget which inherits Django’s SelectMultiple widget

Site

class admin_kit.sites.AdminKitSite(name='admin_kit')[source]

The main AdminKitSite that routes and process url requests.

register(key, ajax_class)[source]

Registers the ajax_class for ajax behaviour

key :: str
This is the key that will be used in models for binding
ajax_class :: class
The ajax class that inherits admin_kit.ajax.Ajax
admin_kit.site.register(key, ajax_class)

Registers the ajax_class for ajax behaviour. This is same as admin_kit.sites.AdminKitSite.register method

key :: str
This is the key that will be used in models for binding
ajax_class :: class
The ajax class that inherits admin_kit.ajax.Ajax

Ajax

class admin_kit.ajax.Ajax[source]

This is the base class for Ajax functionality.

response_type : str
The response type of the API. By default its set to json, It also accepts text.
unique : bool
If True, the key is prepended with class name slug, Thus making it unique per class.
format_response(output)[source]

Formats the response type based on response_type attribute.

classmethod generate_key(key)[source]

A class method that generates key, that maps to the function

If unique attribute is true, then it appends hiphen seperated class name to actual key

Example:

>>> import DummyAjaxClass
>>> DummyAjaxClass.generateKey('the_key')
the_key
>>> DummyAjaxClass.unique = True
>>> DummyAjaxClass.generateKey('the_key')
dummy-ajax-class-the_key
route(request)[source]

For a given request it executes the run method of the module_cls and returns the response

run(request)[source]

This method should be overrided by the child class.