Skip to content

Enforce min_num constraint for inline editing #62

@7tg

Description

@7tg

Description

When updating a model with inlines via update_<model>, the min_num constraint defined on InlineModelAdmin is not enforced.

Current Behavior

The MCP allows having fewer inline objects than required by the min_num setting on the inline admin.

Expected Behavior

The min_num constraint should be validated when:

  • Creating a parent object with inlines
  • Updating inlines (especially when deleting)

If the minimum count is not met, return a validation error.

Django Admin Reference

class ChapterInline(admin.TabularInline):
    model = Chapter
    min_num = 1  # Require at least 1 chapter

Implementation Notes

  • Check inline_admin.min_num after processing inline operations
  • Consider remaining inline count after deletions
  • Return descriptive error when minimum not met

Labels

enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions