Skip to content

Conversation

kevinhowbrook
Copy link

This patch adds compatibility with Wagtail CMS by:

  1. Adding ParentalKey to the RELATIONSHIP_MAP with one-to-many cardinality
  2. Modifying field type detection to use the field's class name for relationship mappings
  3. Adding graceful error handling for unsupported relationship types

This allows django-diagram to work with Wagtail page models that extensively use ParentalKey relationships for their hierarchical structure, while maintaining backward compatibility with standard Django models.

Error without this patch when running:

    self.process_relationship(
  File "/venv/lib/python3.12/site-packages/django_diagram/app.py", line 56, in process_relationship
    ) = self.RELATIONSHIP_MAP[field_type]
        ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ParentalKey'

This patch adds compatibility with Wagtail CMS by:

1. Adding ParentalKey to the RELATIONSHIP_MAP with one-to-many cardinality
2. Modifying field type detection to use the field's class name for relationship mappings
3. Adding graceful error handling for unsupported relationship types

This allows django-diagram to work with Wagtail page models that extensively use ParentalKey relationships for their hierarchical structure, while maintaining backward compatibility with standard Django models.
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.

1 participant