Skip to content

INTPYTHON-624 Add PolymorphicEmbeddedModelField #327

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

Merged
merged 3 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Field.stores_model_instance
  • Loading branch information
timgraham committed Jul 7, 2025
commit f9ebf0a8d33dd64012981f290ddff8aa2e30dba8
2 changes: 1 addition & 1 deletion django_mongodb_backend/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def execute_sql(self, result_type):
elif hasattr(value, "prepare_database_save"):
if field.remote_field:
value = value.prepare_database_save(field)
elif not hasattr(field, "embedded_model"):
elif not getattr(field, "stores_model_instance", False):
raise TypeError(
f"Tried to update field {field} with a model "
f"instance, {value!r}. Use a value compatible with "
Expand Down
2 changes: 2 additions & 0 deletions django_mongodb_backend/fields/embedded_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class EmbeddedModelField(models.Field):
"""Field that stores a model instance."""

stores_model_instance = True

def __init__(self, embedded_model, *args, **kwargs):
"""
`embedded_model` is the model class of the instance to be stored.
Expand Down