Each admin class has to inherit from unfold.admin.ModelAdmin
to get access to all available options. By using django.contrib.admin.ModelAdmin
the options are not going to work and admin pages will be missing styling and features provided by Unfold.
# admin.py
from django import models
from django.contrib import admin
from django.contrib.postgres.fields import ArrayField
from django.db import models
from unfold.admin import ModelAdmin
from unfold.contrib.forms.widgets import ArrayWidget, WysiwygWidget
@admin.register(MyModel)
class CustomAdminClass(ModelAdmin):
# Display fields in changeform in compressed mode
compressed_fields = True # Default: False
# Warn before leaving unsaved changes in changeform
warn_unsaved_form = True # Default: False
# Preprocess content of readonly fields before render
readonly_preprocess_fields = {
"model_field_name": "html.unescape",
"other_field_name": lambda content: content.strip(),
}
# Display submit button in filters
list_filter_submit = False
# Display changelist in fullwidth
list_fullwidth = False
# Set to False, to enable filter as "sidebar"
list_filter_sheet = True
# Position horizontal scrollbar in changelist at the top
list_horizontal_scrollbar_top = False
# Dsable select all action in changelist
list_disable_select_all = False
# Custom actions
actions_list = [] # Displayed above the results list
actions_row = [] # Displayed in a table row in results list
actions_detail = [] # Displayed at the top of for in object detail
actions_submit_line = [] # Displayed near save in object detail
# Changeform templates
change_form_before_template = "some/template.html"
change_form_after_template = "some/template.html"
formfield_overrides = {
models.TextField: {
"widget": WysiwygWidget,
},
ArrayField: {
"widget": ArrayWidget,
}
}
Django admin theme built with Tailwind CSS to bring modern look and feel to your admin interface. Already contains several built-in features for smooth developer experience.
© 2023 - 2024 Created by unfoldadmin.com. All rights reserved.