Skip to content

Commit 177d141

Browse files
committed
Comment out get_models
1 parent bd51b6a commit 177d141

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

netbox_custom_objects/__init__.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,37 @@ def get_model(self, model_name, require_ready=True):
6060

6161
return obj.get_model()
6262

63-
def get_models(self, include_auto_created=False, include_swapped=False):
64-
"""Return all models for this plugin, including custom object type models."""
65-
# Get the regular Django models first
66-
for model in super().get_models(include_auto_created, include_swapped):
67-
yield model
68-
69-
# Skip custom object type model loading if running during migration
70-
if is_running_migration():
71-
return
72-
73-
# Suppress warnings about database calls during model loading
74-
with warnings.catch_warnings():
75-
warnings.filterwarnings(
76-
"ignore", category=RuntimeWarning, message=".*database.*"
77-
)
78-
warnings.filterwarnings(
79-
"ignore", category=UserWarning, message=".*database.*"
80-
)
81-
82-
# Add custom object type models
83-
from .models import CustomObjectType
84-
85-
# Only load models that are already cached to avoid creating all models at startup
86-
# This prevents the "two TaggableManagers with same through model" error
87-
custom_object_types = CustomObjectType.objects.all()
88-
for custom_type in custom_object_types:
89-
# Only yield already cached models during discovery
90-
if CustomObjectType.is_model_cached(custom_type.id):
91-
model = CustomObjectType.get_cached_model(custom_type.id)
92-
if model:
93-
yield model
63+
# def get_models(self, include_auto_created=False, include_swapped=False):
64+
# """Return all models for this plugin, including custom object type models."""
65+
# # Get the regular Django models first
66+
# for model in super().get_models(include_auto_created, include_swapped):
67+
# yield model
68+
#
69+
# # Skip custom object type model loading if running during migration
70+
# if is_running_migration():
71+
# return
72+
#
73+
# # Suppress warnings about database calls during model loading
74+
# with warnings.catch_warnings():
75+
# warnings.filterwarnings(
76+
# "ignore", category=RuntimeWarning, message=".*database.*"
77+
# )
78+
# warnings.filterwarnings(
79+
# "ignore", category=UserWarning, message=".*database.*"
80+
# )
81+
#
82+
# # Add custom object type models
83+
# from .models import CustomObjectType
84+
#
85+
# # Only load models that are already cached to avoid creating all models at startup
86+
# # This prevents the "two TaggableManagers with same through model" error
87+
# custom_object_types = CustomObjectType.objects.all()
88+
# for custom_type in custom_object_types:
89+
# # Only yield already cached models during discovery
90+
# if CustomObjectType.is_model_cached(custom_type.id):
91+
# model = CustomObjectType.get_cached_model(custom_type.id)
92+
# if model:
93+
# yield model
9494

9595

9696
config = CustomObjectsPluginConfig

0 commit comments

Comments
 (0)