Contents

Models

Admin Kit Models module

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=None, choices_form_class=None, **kwargs)[source]

Returns the form object to be used for rendering.

from_db_value(value, *args, **kwargs)[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

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.

db_type(connection)[source]

Sets db_type to either varchar or longtext depending on max_length

deconstruct()[source]

Deconstructs MultiSelect Field

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

Sets form to be used for rendering

get_prep_value(value)[source]

Converts value to a string

to_python(value)[source]

Converts the string value to a list

class admin_kit.models.SelectField(*args, **kwargs)[source]

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

db_type(connection)[source]

Sets db_type to either varchar or longtext depending on max_length

deconstruct()[source]

Deconstructs SelectField

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

Sets form to be used for rendering

Fields

Admin Kit Fields module

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

class admin_kit.fields.SelectField(choices=(), *args, **kwargs)[source]

This field is used to create MultiSelect Form fields.

widget

alias of SelectWidget

Widgets

Admin Kit Widgets module

class admin_kit.widgets.SelectMultipleWidget(attrs=None, choices=())[source]

MultiSelect Widget which inherits Django’s SelectMultiple widget

class Media[source]

This class adds css required for admin_kit’s widget

get_context(name, value, attrs)[source]

Adds appropriate attributes to widget context

class admin_kit.widgets.SelectWidget(attrs=None, choices=())[source]

MultiSelect Widget which inherits Django’s Select widget

get_context(name, value, attrs)[source]

Adds appropriate attributes to widget context

Site

Admin Kit Sites module

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

The main AdminKitSite that routes and process url requests.

ajax(request, key)[source]

Calls route method

get_urls()[source]

Returns the list of urls of admin_kit

js_config(request)[source]

Renders the config.js file which configures global variables

ping(request)[source]

Ping method is used to ping admin_kit ajax

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
urls

The actual property used by django for routing requests

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

Admin Kit Ajax module

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.