Skip to content

Commit

Permalink
Serialize RelatedManager attributes in cache (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaeppe authored Sep 15, 2022
1 parent 29e2b65 commit b34ebe7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions mypy_django_plugin/transformers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,7 @@ def run_with_model_cls(self, model_cls: Type[Model]) -> None:
model_info=related_model_info, derived_from="_default_manager"
)
if default_reverse_manager_info:
self.add_new_node_to_model_class(
attname, Instance(default_reverse_manager_info, []), no_serialize=True
)
self.add_new_node_to_model_class(attname, Instance(default_reverse_manager_info, []))
continue

# The reverse manager we're looking for doesn't exist. So we
Expand All @@ -562,7 +560,6 @@ def run_with_model_cls(self, model_cls: Type[Model]) -> None:
module=self.api.modules[related_model_info.module_name],
name=f"{related_model_cls.__name__}_RelatedManager",
bases=[parametrized_related_manager_type, default_manager_type],
no_serialize=True,
)
new_related_manager_info.metadata["django"] = {"related_manager_to_model": related_model_info.fullname}
# Stash the new reverse manager type fullname on the related model, so we don't duplicate
Expand All @@ -572,7 +569,7 @@ def run_with_model_cls(self, model_cls: Type[Model]) -> None:
derived_from="_default_manager",
fullname=new_related_manager_info.fullname,
)
self.add_new_node_to_model_class(attname, Instance(new_related_manager_info, []), no_serialize=True)
self.add_new_node_to_model_class(attname, Instance(new_related_manager_info, []))


class AddExtraFieldMethods(ModelClassInitializer):
Expand Down

0 comments on commit b34ebe7

Please sign in to comment.