Skip to content

Django Admin

Manage [[Django Models]]

You don't need to create a class <Model>Admin!

from django.contrib import admin
from myapp.models import Author

Using a ModelAdmin
class SecurityUserModelAdmin(admin.ModelAdmin):

Creating your own ModelAdmin

You can override the default ModelAdmin

  • you can create a custom ModelAdmin
  • that always has the buttons the top for example
    • Forma
class MyModelAdmin(admin.ModelAdmin):
    save_on_top = True

Then using it in

Use <input type="text"> instead of <textarea> for TextField

from django.db.models import TextField
from django.forms import TextInput
from django.contrib.admin import ModelAdmin

class PageAdmin(ModelAdmin):

    formfield_overrides = {
        TextField: {"widget": TextInput},
from django.contrib import admin
from django.urls import reverse  
from django.utils.html import format_html

class DashboardAdmin(admin.ModelAdmin):
    list_display = (
        # column header name

    def go_to_permission(dashboard):
        url = reverse("admin:permissions_configurator_permission_change", args=[])
        return format_html('<a href="{}">{}</a>', url,

Reversing Admin URLs


Prevent deletion in Django admin

In Django Admin how do I disable the Delete link - Stack Overflow

Last update: 2023-04-24