List annotation mixin - Django admin extensions

Skip to content

# List annotation mixin

##

## `ListAnnotatorAdminMixin`

Mixin to easily add annotated fields to a select.

Property `list_annotations` may be filled with an annotations definitions:

Examples:

    class SomeAdmin:
        list_annotations = (
            ('participants', models.Count, 'participants_count'),
        )

Where:

- The field name to manupulate(might be None if function does not require it to be).
- The second parameter is the callable that receives field and does something with it. Must return data that can be used as annotation.
- Third parameter - is the resulting field name. May not be present, in that case the name will be `self.LIST_ANNOTATIONS_PREFIX + field`.