File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 11import decimal
22import re
3+ import warnings
34from datetime import date , datetime
45
56import django_filters
3637 ExportTemplatesMixin ,
3738 JournalingMixin ,
3839 NotificationsMixin ,
39- get_model_features ,
4040 TagsMixin ,
41+ get_model_features ,
4142)
4243from netbox .registry import registry
4344from utilities import filters
@@ -439,15 +440,22 @@ def wrapped_post_through_setup(self, cls):
439440
440441 TM .post_through_setup = wrapped_post_through_setup
441442
442- try :
443- model = type (
444- str ( model_name ),
445- ( CustomObject , models . Model ),
446- attrs ,
443+ # Suppress RuntimeWarning about model already being registered
444+ # TODO: Remove this once we have a better way to handle model registration
445+ with warnings . catch_warnings ():
446+ warnings . filterwarnings (
447+ "ignore" , category = RuntimeWarning , message = ".*was already registered.*"
447448 )
448- finally :
449- # Restore the original method
450- TM .post_through_setup = original_post_through_setup
449+
450+ try :
451+ model = type (
452+ str (model_name ),
453+ (CustomObject , models .Model ),
454+ attrs ,
455+ )
456+ finally :
457+ # Restore the original method
458+ TM .post_through_setup = original_post_through_setup
451459
452460 # Register the main model with Django's app registry
453461 try :
You can’t perform that action at this time.
0 commit comments