Skip to main content

Django Admin Customization

Customize Django admin with advanced list displays, inline editing, custom actions, filters, import/export, and role-based dashboards.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Customize the Django admin for order management system to serve as an internal operations dashboard. The main models are Order, Product, Customer, Payment, Shipment. Implement: 1) ModelAdmin for Order with: list_display showing order_number, customer_name, total_amount (formatted as currency), status (colored badge), created_at (humanized) including colored status badges using format_html, list_filter for status, payment_method, created_at range, total_amount range with custom date range filter, search_fields on order_number, customer__name, customer__email, and list_editable for status, priority. 2) Inline admin for OrderItem inline on Order, PaymentAttempt inline on Payment — use TabularInline for compact display with extra=0, min_num=1, and formfield_overrides for TextInput with smaller width for quantity, Select2 for product selection. 3) Custom admin actions: mark as shipped, generate invoices PDF, export selected to CSV, send reminder emails — with confirmation page for destructive actions and progress feedback for batch operations. 4) Custom admin views — add a Sales Dashboard page accessible from the admin sidebar showing daily revenue chart, order count by status, top products this week, built as a custom AdminSite view with proper permission checking. 5) Override change_form_template to add shipping address auto-fills from customer selection, total recalculates on item changes — inline JavaScript for dependent dropdowns, auto-calculated fields, and conditional field visibility. 6) Import/export using django-import-export: configure resources for Product (CSV import with image URLs), Customer (Excel import) with proper validation and error reporting. 7) Role-based admin access: super-admin (full access), operations (orders + shipments), finance (payments + reports), support (read-only customers + orders) with fieldsets that show/hide fields based on user group, and queryset filtering so each role only sees operations sees only their region orders, support sees only their assigned customers.

What this prompt does

This prompt turns the Django admin into an internal operations dashboard for a [project_type], focused on [admin_models]. For the [primary_model] it builds a ModelAdmin with list_display showing [list_columns] (including colored status badges via format_html), list_filter on [filter_fields] with a custom date-range filter, search_fields on [search_fields], and list_editable for [editable_fields].

Beyond the list view it adds TabularInline editing for [inline_models] with extra=0, a min_num of [min_inline], and widget overrides from [widget_overrides], custom bulk actions ([bulk_actions]) with confirmation pages for destructive ones, and a custom admin view named [custom_view_name] showing [custom_view_content]. It overrides change_form_template for [form_customizations] like dependent dropdowns and auto-calculated fields, integrates [import_export_lib] for [importable_models] with validation and error reporting, and enforces role-based access for [admin_roles] with fieldsets that show or hide fields by group and get_queryset filtering per [visibility_rules]. The end result is an admin that operations staff can run their day from rather than a bare CRUD scaffold.

When to use it

  • A client's operations team will live in the admin daily and needs it genuinely usable
  • You want at-a-glance status via colored badges and humanized columns
  • You need inline editing of related rows (order items, payment attempts) on one page
  • You want bulk actions like mark-as-shipped or export-to-CSV with safe confirmations
  • You need CSV/Excel import-export with validation and error reporting
  • Different roles must see different fields and only their own scoped records
  • You'd rather extend the admin than build a separate internal tool from scratch

Example output

The AI returns ModelAdmin classes with format_html badge methods, inline classes with extra=0 and widget overrides, action functions with confirmation templates, a custom AdminSite view for [custom_view_name], a change_form_template override with inline JavaScript for dependent fields, [import_export_lib] resource classes, and role-based get_fieldsets/get_queryset overrides. Expect organized code blocks per numbered feature so you can pull in just the inlines, actions, or role logic you need.

Pro tips

  • Keep list_editable fields in [editable_fields] minimal — making too many columns editable inline invites accidental edits
  • Add a confirmation page for every destructive entry in [bulk_actions], especially deletes and status changes that fan out side effects
  • Use [widget_overrides] (like Select2 for product pickers) so large foreign-key lists stay usable
  • Scope get_queryset by [visibility_rules] so roles like operations or support never see records outside their region or assignment
  • Build the [custom_view_name] page as a proper AdminSite view with permission checks, not an unprotected URL
  • Validate imports for [importable_models] so a malformed row reports a clear error instead of partially loading
  • Add a date-range filter on [filter_fields] so operators can slice records by period without writing a query
  • If badges render as escaped HTML, confirm the method returns format_html(...) and is listed in list_display

Frequently Asked Questions

How does it show colored status badges in the admin list?
It defines a method on the ModelAdmin that wraps the status value in styled markup using `format_html`, then adds that method to `list_display`. Using format_html rather than raw strings keeps the output safe from HTML escaping while rendering the colored badge.
Can different admin roles see different fields and records?
Yes. The prompt implements role-based access for `[admin_roles]` using fieldsets that show or hide fields per group and `get_queryset` filtering per `[visibility_rules]`. So operations might see only their region's orders while finance sees payment fields others can't.
Which library does it use for import and export?
It uses `[import_export_lib]`, with django-import-export as the default. The prompt configures resource classes for `[importable_models]` with validation and error reporting, so a bad CSV row surfaces a clear message instead of failing silently.
Does it support editing related records on the same page?
It does, through TabularInline admin for `[inline_models]` with `extra=0` and a minimum entry count. This lets you edit things like order items directly on the order page, with widget overrides from `[widget_overrides]` to keep the inline compact and usable.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Django & Flask Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support