module documentation

Undocumented

Constant QUOTE​_MAP Undocumented
Constant UNQUOTE​_MAP Undocumented
Constant UNQUOTE​_RE Undocumented
Class ​Field​Is​AForeign​Key​Column​Name A field is a foreign key attname, i.e. <FK>_id.
Class ​Nested​Objects No class docstring; 0/3 instance variable, 2/7 methods documented
Class ​Not​Relation​Field 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.
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 No summary
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 No summary
Function reverse​_field​_path Create a reversed field path.
Function unquote Undo the effects of quote().
QUOTE_MAP =

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

def _get_non_gfk_field(opts, name):

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).

def construct_change_message(form, formsets, add):
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):

Undocumented

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

Undocumented

def flatten(fields):
Return a list which is a single level of flattening of the original list.
def flatten_fieldsets(fieldsets):
Return a list of field names from an admin fieldsets structure.
def get_deleted_objects(objs, request, admin_site):

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):

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):

Undocumented

def help_text_for_field(name, model):

Undocumented

def label_for_field(name, model, model_admin=None, return_attr=False, form=None):
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):

Undocumented

def lookup_spawns_duplicates(opts, lookup_path):
Return True if the given lookup path spawns duplicates.
def model_format_dict(obj):

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):

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):
Return a lookup value prepared to be used in queryset filtering.
def quote(s):
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):

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):
Undo the effects of quote().