I figured out what the problem was while writing this question. I post it anyway in case it could help someone else.
The error: ‘FooAdmin.fieldsets[0][1][‘fields’]’ refers to field ‘date’ that is missing from the form.
With the following code:
# models.py
from django.db import models
class Foo(Base):
date = models.DateField(auto_now_add=True)
title = models.CharField(max_length=255)
# admin.py
from django.contrib import admin
class FooAdmin(BaseAdmin):
list_display = ("title", "date")
fieldsets = (
(None, {
"fields": ("date", "title")
}),
)
admin.site.register(Foo, FooAdmin)
The error is due to date having
auto_now_add=True(orauto_now=True).As the value is automatic, it’s not editable, so it’s not in the form. To solve that, add this in
FooAdmin: