Skip to content

Conversation

bctiemann
Copy link
Contributor

@bctiemann bctiemann commented Aug 25, 2025

Fixes: #101

Adds a LazyForeignKey class to handle self-referential single Object fields.

Adds circular import/recursion detection and skips object/multiobject field resolution on 2nd-level (related) object fields to avoid infinite loops.

Enables both single-object and multi-object self-referential field operation as shown below.

Screenshot 2025-08-25 at 7 41 42 PM Screenshot 2025-08-25 at 6 31 10 PM

@bctiemann bctiemann requested a review from arthanson August 25, 2025 17:49
@bctiemann bctiemann changed the base branch from main to feature August 25, 2025 17:49
@bctiemann
Copy link
Contributor Author

I had to reinstate the previous logic branch for cross-referential single object fields instead of using LazyForeignKey for both; strangely, with that change the UI functionality worked fine, but running the tests caused an error like ValueError: Cannot assign "<Table338Model: Second Object>": "Table337Model.related_object" must be a "Table338Model" instance. which was the reason for creating the LazyForeignKey in the first place.

I have yet to understand why the UI and the raw code work differently, and maybe it can be streamlined later, but for now at least both conditions work.

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.

Creating a Custom Object Field of type object to another custom objects gives UI recursive error
2 participants