Admin
Django admin utility module for field management and filtering.
This module provides utility functions and constants for configuring Django admin views, particularly focused on field filtering and display configurations.
Attributes:
Name | Type | Description |
---|---|---|
related_field_set |
Set[Type]
|
Set of Django field types that represent relations. |
complex_field_set |
Set[Type]
|
Set of Django field types considered complex. |
list_display_user_admin |
List[str]
|
Default display fields for User admin interface. |
list_display_exclude |
List[Type]
|
Field types to exclude from admin list display. |
list_filter_base |
List[str]
|
Base filter fields for standard admin views. |
list_filter_base_public_contribute |
List[str]
|
Extended filter fields including verification status. |
django_meta_get_fields(django_object, field_types, exclude=True)
Gets field names from a Django model based on specified field types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
django_object
|
Model
|
Django model instance or class to inspect. |
required |
field_types
|
List[Type[Field]]
|
List of Django field types to filter by. |
required |
exclude
|
bool
|
Whether to exclude or include the specified field types. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of field names that match the filtering criteria. |
Example
fields = django_meta_get_fields(MyModel, [ManyToManyField], exclude=True) print(fields) ['id', 'name', 'description']
Source code in django_util/admin.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
django_meta_get_fields_exclude(django_object, to_exclude=list_display_exclude)
Convenience wrapper for django_meta_get_fields that excludes specified field types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
django_object
|
Any
|
Django model instance or class to inspect. |
required |
to_exclude
|
List[Type]
|
List of field types to exclude. Defaults to list_display_exclude. |
list_display_exclude
|
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of field names excluding the specified field types. |
Source code in django_util/admin.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
django_meta_get_fields_include(django_object, to_include=[ManyToManyField])
Convenience wrapper for django_meta_get_fields that includes only specified field types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
django_object
|
Any
|
Django model instance or class to inspect. |
required |
to_include
|
List[Type]
|
List of field types to include. Defaults to [ManyToManyField]. |
[ManyToManyField]
|
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of field names matching the specified field types. |
Source code in django_util/admin.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|