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 1
1
import decimal
2
2
import re
3
+ import warnings
3
4
from datetime import date , datetime
4
5
5
6
import django_filters
36
37
ExportTemplatesMixin ,
37
38
JournalingMixin ,
38
39
NotificationsMixin ,
39
- get_model_features ,
40
40
TagsMixin ,
41
+ get_model_features ,
41
42
)
42
43
from netbox .registry import registry
43
44
from utilities import filters
@@ -439,15 +440,22 @@ def wrapped_post_through_setup(self, cls):
439
440
440
441
TM .post_through_setup = wrapped_post_through_setup
441
442
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.*"
447
448
)
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
451
459
452
460
# Register the main model with Django's app registry
453
461
try :
You can’t perform that action at this time.
0 commit comments