How to configure django built-in admin form deletion function

How to configure django inline. My admin.py setting is below.

#admin.py
class ChildModelInline(admin.TabularInline):
    model = ChildModel
    can_delete = True

#admin.py
@admin.register(ParentModel)
class ParentModelAdmin(admin.ModelAdmin):
    inlines = [ChildModelInline,]

ChildModel is associated with ParentModel using the models.ForeignKey field. I would like to be able to select multiple child objects in the ParentModel inline form to delete, but not remove the child from the database, just delete the ForeignKey relationship in the child.

Thank!

+4
source share

Source: https://habr.com/ru/post/1666341/


All Articles