djadmin_inspect Command Reference¶
The djadmin_inspect management command provides deep introspection into registered ModelAdmin configurations, helping developers understand how their admin is configured and how plugins are contributing to the admin interface.
Overview¶
This command is essential for: - Debugging: Understanding why your admin behaves a certain way - Plugin Discovery: Seeing which plugins provide which features - View Composition: Understanding the class hierarchy including plugin-injected mixins - Development: Quickly checking admin configuration during development
Basic Usage¶
# Inspect all registered admins
python manage.py djadmin_inspect
# Inspect a specific model
python manage.py djadmin_inspect --model myapp.MyModel
# Inspect a specific ModelAdmin class
python manage.py djadmin_inspect --admin myapp.MyModelAdmin
# Use JSON format for machine parsing
python manage.py djadmin_inspect --format json
# Filter by action type
python manage.py djadmin_inspect --actions bulk
Command Options¶
--model MODEL_PATH¶
Inspect all ModelAdmin instances registered for a specific model.
Format: app_label.ModelName
Example:
--admin ADMIN_CLASS_PATH¶
Inspect a specific ModelAdmin class by its dotted import path.
Format: module.path.AdminClassName
Example:
--format {table,json,tree}¶
Choose the output format.
table(default): Human-readable table formatjson: Machine-readable JSON for parsing/automationtree: Tree view with hierarchical structure (currently same as table)
Example:
# JSON format for scripting
python manage.py djadmin_inspect --format json > admin_config.json
# Tree format for viewing structure
python manage.py djadmin_inspect --format tree
--actions {general,bulk,record,all}¶
Filter output to show only specific action types.
general: Main entry points (ListView, Add)bulk: Operations on multiple selected recordsrecord: Operations on individual records (Edit, Delete)all(default): Show all action types
Example:
# See only bulk actions
python manage.py djadmin_inspect --model webshop.Product --actions bulk
# See only record actions
python manage.py djadmin_inspect --actions record
--site SITE_PATH¶
Specify which AdminSite instance to inspect (if you have multiple admin sites).
Format: Dotted path to AdminSite instance
Default: djadmin.site
Example:
Output Sections¶
Actions Section¶
Shows all actions registered for the admin:
ACTIONS:
General Actions:
- ListAction → ProductListView
- AddAction → ProductAddView
Form: ProductForm
Bulk Actions:
- DeleteBulkAction → ProductDeleteBulkView
Record Actions:
- EditAction → ProductEditRecordView
Form: ProductForm
- DeleteAction → ProductDeleteRecordView
What it shows: - Action class name - Generated view class name - Form class (for form-based actions) - Layout information (if configured)
View Composition Section¶
Shows the base class and mixins for view classes:
GENERAL ACTION EXAMPLE (ListAction):
View: ProductListView
Base Class: ListView (Django)
Mixins:
- DjAdminFiltersMixin (plugin)
- DjAdminViewMixin (djadmin core)
- SearchMixin (djadmin core)
What it shows:
- Base Class: The main Django CBV (e.g., ListView, FormView)
- Mixins: Additional mixins added by djadmin core and plugins
- Origin: Where each class comes from:
- (Django): Standard Django class
- (djadmin core): From djadmin core package
- (plugin): From a plugin package
- (external): From external library (e.g., django-formset)
Features Section¶
Shows requested features and which plugins provide them:
REQUESTED FEATURES:
- search (provided by: available)
- ordering (provided by: available)
- filter (provided by: available)
What it shows:
- Features requested by the ModelAdmin configuration
- Availability status (available or NOT PROVIDED)
If a feature shows NOT PROVIDED, you need to install the appropriate plugin.
Templates Section¶
Shows template resolution order:
TEMPLATES (resolution order):
- djadmin/webshop/product_list.html
- djadmin/webshop/product_create.html
- djadmin/webshop/product_update.html
- djadmin/{app}/{model}_list.html or actions/list.html
- djadmin/model_create.html
- djadmin/model_update.html
What it shows: - Model-specific templates (checked first) - Generic fallback templates
JSON Output Format¶
The JSON format provides the same information in a structured format suitable for automation:
[
{
"admin_class": "ProductAdmin",
"admin_module": "examples.webshop.djadmin",
"model": "webshop.Product",
"model_name": "product",
"app_label": "webshop",
"actions": {
"general": [
{
"action_class": "ListAction",
"action_module": "djadmin.actions.list_view",
"label": "List",
"url_name": "webshop_product_list",
"view_class": "ProductListView",
"view_base_class": {
"name": "ListView",
"module": "django.views.generic.list",
"is_django": true,
"is_djadmin": false
},
"view_mixins": [
{
"name": "DjAdminFiltersMixin",
"module": "djadmin_filters.mixins",
"is_django": false,
"is_djadmin": true
}
]
}
],
"bulk": [...],
"record": [...]
},
"features": {
"requested": ["search", "ordering", "filter"],
"provided_by": {
"search": "available",
"ordering": "available",
"filter": "available"
}
},
"templates": [...]
}
]
Common Use Cases¶
Debugging Why a Feature Isn't Working¶
If search isn't working on your admin:
Check the REQUESTED FEATURES section:
- If search is NOT listed → You haven't configured search_fields
- If search shows NOT PROVIDED → You need to install the search plugin
Understanding Plugin Contributions¶
To see which mixins plugins are adding:
Look at the Mixins section under any action example to see: - Which mixins are from core vs plugins - The order in which mixins are applied
Checking Form Configuration¶
To verify which form is being used:
Look for Form: lines under record actions to see:
- Which form class is used (custom or auto-generated)
- Form module location
Finding URL Names¶
To get the URL name for a specific action:
python manage.py djadmin_inspect --model myapp.MyModel --format json | jq '.actions.general[].url_name'
Returns URL names like:
- myapp_mymodel_list
- myapp_mymodel_add
- myapp_mymodel_edit
Comparing Multiple Admins¶
To see how different models are configured:
# Save all admin configs
python manage.py djadmin_inspect --format json > all_admins.json
# Compare specific models
python manage.py djadmin_inspect --model app1.Model1 > model1.txt
python manage.py djadmin_inspect --model app2.Model2 > model2.txt
diff model1.txt model2.txt
Tips & Tricks¶
Quick View MRO Check¶
To quickly see what mixins are applied to ListView:
python manage.py djadmin_inspect --model myapp.MyModel --actions general | grep -A 20 "GENERAL ACTION"
Find All Models with Search¶
python manage.py djadmin_inspect --format json | jq '.[] | select(.features.requested | contains(["search"])) | .model'
Export for Documentation¶
Generate documentation for all admins:
Troubleshooting¶
No Admins Found¶
Issue: Command shows "No admins found"
Solutions:
1. Check that your ModelAdmin is registered: site.register(Model, Admin)
2. Verify the model path is correct: app_label.ModelName
3. Ensure the admin module is imported (usually in djadmin.py)
Failed to Load Site¶
Issue: Failed to load site 'path.to.site': ...
Solutions:
1. Check the site path is correct (dotted Python import path)
2. Verify the site instance exists and is importable
3. Default is djadmin.site, only use --site if you have a custom site
AttributeError or KeyError¶
Issue: Command crashes with AttributeError/KeyError
This is a bug - please report it with: 1. The full command you ran 2. The model/admin you were inspecting 3. The full traceback
Related Commands¶
python manage.py shell: Interactive introspection using Pythonpython manage.py show_urls: Show all registered URLs (django-extensions)python manage.py diffsettings: Show active settings