1π
β
I think https://code.djangoproject.com/ticket/15602 prevents you from doing what you want.
If you split it into two inline admins, one for listing and one for adding, you can achieve what you want, but I donβt like this solution:
class CommentListInline(admin.TabularInline):
model = Comment
fields = ('comment',)
readonly_fields = fields
extra = 0
can_delete = False
def has_add_permission(self, request):
return False
class CommentAddInline(admin.TabularInline):
model = Comment
fields = ('comment',)
extra = 1
can_delete = False
def has_change_permission(self, request, obj=None):
return False
class PageAdmin(admin.ModelAdmin):
inlines = [CommentListInline, CommentAddInline]
π€chlunde
Source:stackexchange.com