module documentation

Undocumented

Class NestedObjects No class docstring; 0/3 instance variable, 2/7 methods documented
Exception FieldIsAForeignKeyColumnName A field is a foreign key attname, i.e. <FK>_id.
Exception NotRelationField Undocumented
Function construct_change_message Construct a JSON structure describing changes from a changed object. Translations are deactivated so that strings are stored untranslated. Translation happens later on LogEntry access.
Function display_for_field Undocumented
Function display_for_value Undocumented
Function flatten Return a list which is a single level of flattening of the original list.
Function flatten_fieldsets Return a list of field names from an admin fieldsets structure.
Function get_deleted_objects Find all objects related to ``objs`` that should also be deleted. ``objs`` must be a homogeneous iterable of objects (e.g. a QuerySet).
Function get_fields_from_path Return list of Fields given path relative to model.
Function get_model_from_relation Undocumented
Function help_text_for_field Undocumented
Function label_for_field Return a sensible label for a field name. The name can be a callable, property (but not created with @property decorator), or the name of an object's attribute, as well as a model field. If return_attr is True, also return the resolved attribute (which could be a callable)...
Function lookup_field Undocumented
Function lookup_spawns_duplicates Return True if the given lookup path spawns duplicates.
Function model_format_dict Return a `dict` with keys 'verbose_name' and 'verbose_name_plural', typically for use with string formatting.
Function model_ngettext Return the appropriate `verbose_name` or `verbose_name_plural` value for `obj` depending on the count `n`.
Function prepare_lookup_value Return a lookup value prepared to be used in queryset filtering.
Function quote Ensure that primary key values do not confuse the admin URLs by escaping any '/', '_' and ':' and similarly problematic characters. Similar to urllib.parse.quote(), except that the quoting is slightly different so that it doesn't get automatically unquoted by the web browser.
Function reverse_field_path Create a reversed field path.
Function unquote Undo the effects of quote().
Constant QUOTE_MAP Undocumented
Constant UNQUOTE_MAP Undocumented
Constant UNQUOTE_RE Undocumented
Function _get_changed_field_labels_from_form Undocumented
Function _get_non_gfk_field For historical reasons, the admin app relies on GenericForeignKeys as being "not found" by get_field(). This could likely be cleaned up.
def construct_change_message(form, formsets, add): (source)

Construct a JSON structure describing changes from a changed object. Translations are deactivated so that strings are stored untranslated. Translation happens later on LogEntry access.

def display_for_field(value, field, empty_value_display): (source)

Undocumented

def display_for_value(value, empty_value_display, boolean=False): (source)

Undocumented

def flatten(fields): (source)

Return a list which is a single level of flattening of the original list.

def flatten_fieldsets(fieldsets): (source)

Return a list of field names from an admin fieldsets structure.

def get_deleted_objects(objs, request, admin_site): (source)

Find all objects related to ``objs`` that should also be deleted. ``objs`` must be a homogeneous iterable of objects (e.g. a QuerySet). Return a nested list of strings suitable for display in the template with the ``unordered_list`` filter.

def get_fields_from_path(model, path): (source)

Return list of Fields given path relative to model. e.g. (ModelX, "user__groups__name") -> [ <django.db.models.fields.related.ForeignKey object at 0x...>, <django.db.models.fields.related.ManyToManyField object at 0x...>, <django.db.models.fields.CharField object at 0x...>, ]

def get_model_from_relation(field): (source)

Undocumented

def help_text_for_field(name, model): (source)

Undocumented

def label_for_field(name, model, model_admin=None, return_attr=False, form=None): (source)

Return a sensible label for a field name. The name can be a callable, property (but not created with @property decorator), or the name of an object's attribute, as well as a model field. If return_attr is True, also return the resolved attribute (which could be a callable). This will be None if (and only if) the name refers to a field.

def lookup_field(name, obj, model_admin=None): (source)

Undocumented

def lookup_spawns_duplicates(opts, lookup_path): (source)

Return True if the given lookup path spawns duplicates.

def model_format_dict(obj): (source)

Return a `dict` with keys 'verbose_name' and 'verbose_name_plural', typically for use with string formatting. `obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.

def model_ngettext(obj, n=None): (source)

Return the appropriate `verbose_name` or `verbose_name_plural` value for `obj` depending on the count `n`. `obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance. If `obj` is a `QuerySet` instance, `n` is optional and the length of the `QuerySet` is used.

def prepare_lookup_value(key, value, separator=','): (source)

Return a lookup value prepared to be used in queryset filtering.

def quote(s): (source)

Ensure that primary key values do not confuse the admin URLs by escaping any '/', '_' and ':' and similarly problematic characters. Similar to urllib.parse.quote(), except that the quoting is slightly different so that it doesn't get automatically unquoted by the web browser.

def reverse_field_path(model, path): (source)

Create a reversed field path. E.g. Given (Order, "user__groups"), return (Group, "user__order"). Final field must be a related model, not a data field.

def unquote(s): (source)

Undo the effects of quote().

QUOTE_MAP = (source)

Undocumented

Value
{i: ('_%02X' % i) for i in b'":/_#?;@&=+$,"[]<>%\n\\'}
UNQUOTE_MAP = (source)

Undocumented

Value
{v: chr(k) for k, v in QUOTE_MAP.items()}
UNQUOTE_RE = (source)

Undocumented

Value
_lazy_re_compile('_(?:%s)'%"""|""".join([x[1:] for x in UNQUOTE_MAP]))
def _get_changed_field_labels_from_form(form, changed_data): (source)

Undocumented

def _get_non_gfk_field(opts, name): (source)

For historical reasons, the admin app relies on GenericForeignKeys as being "not found" by get_field(). This could likely be cleaned up. Reverse relations should also be excluded as these aren't attributes of the model (rather something like `foo_set`).