Jump to >


Admin-specific form widgets.

class RelatedUserWidget(local_site_name=None, multivalued=True)[source]

Bases: django.forms.widgets.HiddenInput

A form widget to allow people to select one or more User relations.

It’s not unheard of to have a server with thousands or tens of thousands of registered users. In this case, the existing Django admin widgets fall down hard. The filtered select widgets can actually crash the webserver due to trying to pre-populate an enormous <select> element, and the raw ID widget is basically a write-only field.

This field does much better, offering both the ability to see who’s already in the list, as well as interactive search and filtering.

is_hidden = False[source]
__init__(local_site_name=None, multivalued=True)[source]

Initalize the RelatedUserWidget.

  • local_site_name (unicode, optional) – The name of the LocalSite where the widget is being rendered.
  • multivalued (bool, optional) – Whether or not the widget should allow selecting multiple values.
render(name, value, attrs=None)[source]

Render the widget.

  • name (unicode) – The name of the field.
  • value (list or None) – The current value of the field.
  • attrs (dict) – Attributes for the HTML element.

The rendered HTML.

Return type:


value_from_datadict(data, files, name)[source]

Unpack the field’s value from a datadict.

  • data (dict) – The form’s data.
  • files (dict) – The form’s files.
  • name (unicode) – The name of the field.

The list of PKs of User objects.

Return type: