FastAPI Mongo Admin

Getting Started

  • Installation
    • Requirements
    • Install the package
    • Development install
    • Optional: MongoDB via Docker
    • Next steps
  • Quick Start
    • 1. Define Pydantic models
    • 2. Create ModelAdmin classes
    • 3. Mount in FastAPI (async)
    • 4. Sync MongoDB (PyMongo)
    • 5. Visit the admin
    • Add authentication
    • Complete example
  • Architecture
    • High-level overview
    • Core components
    • Request flow: changelist
    • Request flow: add/change form
    • HTMX integration
    • Template resolution

Core Concepts

  • AdminSite
    • Default site
    • Custom AdminSite
      • Branding attributes
    • Registering models
      • Single model
      • Multiple models with the same admin class
      • Inline options
    • Registering custom views
    • Template directories
    • CSRF tokens
  • ModelAdmin
    • Basic configuration
    • Configuration reference
      • Template overrides
    • Display columns
      • Field names
      • @display decorator
    • Fieldsets
    • Readonly fields
    • Choices
    • Date hierarchy
    • List select related
    • Date and time display
    • Object representation
    • Configurable methods
  • Authentication
    • Basic setup
    • Global permission gate
    • Bearer token example
    • Cookie-based example
    • No authentication (development only)
    • Ecommerce demo auth
    • JSON API authentication
    • Per-model permissions
    • CSRF protection
  • Permissions
    • Permission hooks
    • Basic example
    • Role-based access
    • Object-level permissions
    • Bulk action permissions
    • Action-level permissions
    • Permission denied responses
    • How checks are wired

Changelist & Forms

  • List Filters
    • Field name filters
      • Auto-selection rules
    • Built-in filter classes
      • BooleanFieldListFilter
      • DateFieldListFilter
      • ChoiceListFilter
      • RelatedFieldListFilter
    • Custom ListFilter
    • Field mapping integration
    • Query parameter names
    • Date hierarchy
  • Forms and Fields
    • Widget inference
    • Formfield overrides
      • Shorthand dict syntax
      • FieldWidget dataclass
    • Per-field hook
    • Fieldsets
    • Readonly fields
    • Form validation
    • Complex field types
      • Nested Pydantic models
      • Nested objects (dict)
      • Lists
      • Decimals
      • Dates and datetimes
      • Booleans
    • Choices in forms
  • Date, Time, and Save Messages
    • Date and time display
      • Default formats
      • Configuration
      • Hooks
    • Save notifications
      • Internationalization
  • Field Mapping
    • Use cases
    • Configuration
    • What gets translated
      • Read operations
      • Write operations
      • Queries
      • List filters
    • Example
    • Implementation
    • Troubleshooting
  • Actions
    • Defining actions
    • The @action decorator
    • Built-in delete action
    • Control which custom actions appear
      • Default (actions = None)
      • Disable custom actions only
    • Import and export
    • How bulk actions work
    • The queryset parameter

Customization

  • Template Customization
    • Template search order
    • Site-wide template directory
    • Per-model template overrides
    • Bundled templates
    • Starting from bundled templates
    • Template context variables
      • Index (admin/index.html)
      • Changelist (admin/change_list.html)
      • Change form (admin/change_form.html)
      • Translation helper
    • Static assets
    • HTMX partials
    • Ecommerce example
  • Custom Admin Views
    • Basic registration
    • Parameters
    • Permission callback
    • Using admin styles
    • Returning Jinja2 templates
    • Model-specific URLs
    • Ecommerce dashboard example
  • Lifecycle Hooks
    • Query hooks
      • get_queryset
    • Persistence hooks
      • save_model
      • delete_model
    • Display hooks
      • display_value
    • Form hooks
      • formfield_for_field
      • get_readonly_fields
      • get_fieldsets
    • Permission hooks
    • Hook execution order
  • Internationalization and Themes
    • Supported languages
    • Language selection
    • Theme toggle
    • RTL support
    • Template usage
    • Preference API
      • Programmatic cookie setting
    • Adding translations
    • Customizing translations
    • CSS themes

Reference

  • Database Backends
    • Async mode (Motor)
    • Sync mode (PyMongo)
    • Backend protocol
    • CollectionRepository
    • Related backends
    • BSON serialization
    • Connection configuration
    • Testing with mongomock
  • JSON API
    • Enable write endpoints
    • Endpoints
      • Read (always available)
        • List documents
        • Get single document
      • Write (api_write_methods=True)
    • OpenAPI / Swagger
    • Authentication
    • Errors
    • Use cases
    • Limitations
    • Custom prefix
  • URL Reference
    • Site routes
    • Model CRUD routes
      • Changelist query parameters
    • JSON API routes
    • Custom views
    • Model-specific URLs
    • Custom router prefix
    • Mounting manually
  • API Reference
    • Package exports
      • mount_admin_app()
      • create_admin_router()
      • serialize_document()
    • Admin registry
      • AdminSite
        • AdminSite.site_header
        • AdminSite.site_title
        • AdminSite.index_title
        • AdminSite.register()
        • AdminSite.register_view()
        • AdminSite.get_model_admin()
        • AdminSite.get_registered_collections()
        • AdminSite.get_registered_models()
        • AdminSite.get_csrf_token()
      • ModelAdmin
        • ModelAdmin.collection_name
        • ModelAdmin.list_display
        • ModelAdmin.list_display_links
        • ModelAdmin.list_editable
        • ModelAdmin.list_filter
        • ModelAdmin.search_fields
        • ModelAdmin.list_per_page
        • ModelAdmin.list_max_show_all
        • ModelAdmin.ordering
        • ModelAdmin.date_hierarchy
        • ModelAdmin.list_select_related
        • ModelAdmin.fieldsets
        • ModelAdmin.readonly_fields
        • ModelAdmin.field_mapping
        • ModelAdmin.actions
        • ModelAdmin.choices
        • ModelAdmin.formfield_overrides
        • ModelAdmin.date_format
        • ModelAdmin.datetime_format
        • ModelAdmin.change_list_template
        • ModelAdmin.change_form_template
        • ModelAdmin.delete_confirmation_template
        • ModelAdmin.delete_selected_confirmation_template
        • ModelAdmin.model
        • ModelAdmin.get_model_name()
        • ModelAdmin.get_model_name_plural()
        • ModelAdmin.get_list_display()
        • ModelAdmin.get_list_display_links()
        • ModelAdmin.get_search_fields()
        • ModelAdmin.get_ordering()
        • ModelAdmin.get_sortable_field()
        • ModelAdmin.get_readonly_fields()
        • ModelAdmin.get_formfield_overrides()
        • ModelAdmin.formfield_for_field()
        • ModelAdmin.get_fieldsets()
        • ModelAdmin.get_list_filters()
        • ModelAdmin.get_actions()
        • ModelAdmin.get_queryset()
        • ModelAdmin.save_model()
        • ModelAdmin.delete_model()
        • ModelAdmin.has_view_permission()
        • ModelAdmin.has_add_permission()
        • ModelAdmin.has_change_permission()
        • ModelAdmin.has_delete_permission()
        • ModelAdmin.get_urls()
        • ModelAdmin.get_date_format()
        • ModelAdmin.get_datetime_format()
        • ModelAdmin.format_date_value()
        • ModelAdmin.format_datetime_value()
        • ModelAdmin.boolean_display_cell()
        • ModelAdmin.format_display_value()
        • ModelAdmin.display_value()
        • ModelAdmin.object_repr()
    • Decorators
      • display()
      • action()
    • Actions
      • run_delete_selected()
      • get_model_actions()
    • List filters
      • ListFilter
        • ListFilter.title
        • ListFilter.parameter_name
        • ListFilter.lookups()
        • ListFilter.queryset()
        • ListFilter.choices()
        • ListFilter.db_field()
      • ChoiceListFilter
        • ChoiceListFilter.title
        • ChoiceListFilter.lookups()
        • ChoiceListFilter.queryset()
      • BooleanFieldListFilter
        • BooleanFieldListFilter.title
        • BooleanFieldListFilter.lookups()
        • BooleanFieldListFilter.queryset()
      • DateFieldListFilter
        • DateFieldListFilter.title
        • DateFieldListFilter.lookups()
        • DateFieldListFilter.queryset()
      • build_date_hierarchy_query()
      • RelatedFieldListFilter
        • RelatedFieldListFilter.related_collection
        • RelatedFieldListFilter.related_field
        • RelatedFieldListFilter.display_field
        • RelatedFieldListFilter.lookups()
        • RelatedFieldListFilter.queryset()
    • Field widgets
      • is_primitive_list()
      • widget_for_type()
      • step_for_type()
      • FieldWidget
        • FieldWidget.widget
        • FieldWidget.attrs
        • FieldWidget.from_mapping()
      • apply_field_widget_override()
    • Mount helpers
      • get_static_directory()
      • mount_admin_app()
    • Router
      • create_admin_router()
    • Repository
      • related_object_label()
      • CollectionRepository
        • CollectionRepository.list_documents()
        • CollectionRepository.get_document()
        • CollectionRepository.create_document()
        • CollectionRepository.update_document()
        • CollectionRepository.delete_document()
        • CollectionRepository.delete_many()
        • CollectionRepository.get_related_form_initial()
        • CollectionRepository.search_related_documents()
        • CollectionRepository.set_related_backend()
    • Formatting
      • parse_datetime()
      • parse_date()
      • format_date_display()
      • format_datetime_display()
    • Schema utilities
      • serialize_document()
      • prepare_for_mongodb()
      • format_field_value()
      • infer_admin_fields()
      • prepare_form_fields()
      • infer_schema_dict()
      • parse_form_to_model()
    • Field mapping
      • translate_to_db()
      • translate_from_db()
      • translate_query()
    • Exceptions
      • AdminException
        • AdminException.error_code
        • AdminException.details
      • DocumentNotFoundError
      • CollectionNotFoundError
      • InvalidQueryError
      • ValidationError
      • PermissionDeniedError
    • Internationalization
      • Translator
        • Translator.gettext()
        • Translator.ngettext()
  • Ecommerce Demo
    • Quick start
    • Project structure
    • Registered collections
    • Features demonstrated
    • Authentication
    • Seeding
    • Environment variables (app)
    • Customization recipes
  • Migration from v0.x
    • Summary of breaking changes
    • Step-by-step migration
      • 1. Update installation
      • 2. Replace mount call
      • 3. Define ModelAdmin classes
      • 4. Add authentication
      • 5. Update URL references
      • 6. Remove React-specific code
    • New features in v2
    • Configuration mapping
    • Need help?
FastAPI Mongo Admin
  • Search


© Copyright 2026, Taiwo Kareem.

Built with Sphinx using a theme provided by Read the Docs.