Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natural key (Django serialization) support for Wagtail models #11729

Open
ElectronicRU opened this issue Mar 5, 2024 · 0 comments
Open

Natural key (Django serialization) support for Wagtail models #11729

ElectronicRU opened this issue Mar 5, 2024 · 0 comments

Comments

@ElectronicRU
Copy link

Is your proposal related to a problem?

I'm trying to transfer data between application environments, and existing packages don't fit my use case. A great boon in doing so would be to be able to use Django's serialization framework for Wagtail models. Additionally, it would simplify test fixture generation.

Describe the solution you'd like

Some Wagtail models have a, well, natural natural key, in that they're looked up by it in normal site operation.

  • Site objects are looked up by hostname and port.
  • Page objects are looked up by url_path, which uniquely defines the hierarchy.

Some models feel like it should be workable, but I'm not sure:

  • Collection objects don't have materialized paths of any sort (except for MP_Node's). However, a list of names from root to self is likely a workable natural key.
  • Image model seems to be designed to have a one-to-one relationship with files, and file path could be a natural key. However, model users may adjust this behavior without overriding natural_key, so this is a potential incompatibility point.

Describe alternatives you've considered

Some libraries I've tried:

  • wagtail_import_export, wagtail_import_export_tool - don't support model references in StreamFields
  • wagtail_transfer - has problems with dependency loops that close over StreamFields
  • coderedcms - dropped export support.

Django serialization framework seems pretty great for this purpose, since it already knows how to load objects with circular dependencies.

Working on this

I'm probably going to do this anyway, but I feel the scope of this proposal is limited enough to be included upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant