1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Tweak registry initialization

This commit is contained in:
jeremystretch
2022-01-19 15:22:28 -05:00
parent cdae0c2bef
commit 047bed2a86
2 changed files with 12 additions and 9 deletions

View File

@ -1,5 +1,3 @@
import collections
from django.db.models import Q
from django.utils.deconstruct import deconstructible
from taggit.managers import _TaggableManager
@ -58,12 +56,8 @@ class FeatureQuery:
def register_features(model, features):
if 'model_features' not in registry:
registry['model_features'] = {
f: collections.defaultdict(list) for f in EXTRAS_FEATURES
}
for feature in features:
if feature not in EXTRAS_FEATURES:
raise ValueError(f"{feature} is not a valid extras feature!")
app_label, model_name = model._meta.label_lower.split('.')
registry['model_features'][feature][app_label].append(model_name)
registry['model_features'][feature][app_label].add(model_name)