Skip to content

Add relationship detection and display support#63

Open
glennswest wants to merge 1 commit intobenavlabs:mainfrom
glennswest:feature/relationship-support
Open

Add relationship detection and display support#63
glennswest wants to merge 1 commit intobenavlabs:mainfrom
glennswest:feature/relationship-support

Conversation

@glennswest
Copy link

Summary

  • Add support for detecting and displaying SQLAlchemy relationships in the admin interface
  • New relationships.py module that detects BelongsTo, HasOne, HasMany, and ManyToMany relationships
  • Auto-detects suitable display fields for related models (name, title, hostname, etc.)

Changes

  • New file: admin_interface/relationships.py - Core relationship detection logic
  • New templates:
    • related_link.html - Link to related model
    • related_single.html - Display single related record
    • related_table.html - Display multiple related records
  • Updated: admin_site.py, model_view.py - Integration with relationship detection
  • Updated: create.html, update.html, list_content.html - Display related data

Features

  • Automatically detects relationships defined on SQLAlchemy models
  • Loads and displays related data in create/update forms
  • Shows relationship summaries in list views
  • Supports foreign key relationships in both directions

Test plan

  • Test with models that have foreign key relationships
  • Verify BelongsTo relationships show parent record info
  • Verify HasMany relationships show child record counts
  • Test create/update forms with relationship fields

Features:
- New relationships.py module for detecting SQLAlchemy relationships
- Support for BelongsTo, HasOne, HasMany, and ManyToMany relationships
- Auto-detect display fields for related models (name, title, etc.)
- Load and display related data in model views
- New templates for related data display (related_link, related_single, related_table)
- Updated create/update forms to show relationship context
- Updated list view to show relationship summaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants