Closes #17482: Ignore Branch & StagedChange in nbshell

This commit is contained in:
Jeremy Stretch 2024-09-12 16:27:21 -04:00
parent fa1e89d3d2
commit 65f81ab81d

View File

@ -11,6 +11,10 @@ from core.models import ObjectType
from users.models import User
APPS = ('circuits', 'core', 'dcim', 'extras', 'ipam', 'tenancy', 'users', 'virtualization', 'vpn', 'wireless')
EXCLUDE_MODELS = (
'extras.branch',
'extras.stagedchange',
)
BANNER_TEXT = """### NetBox interactive shell ({node})
### Python {python} | Django {django} | NetBox {netbox}
@ -44,12 +48,16 @@ class Command(BaseCommand):
# Gather Django models and constants from each app
for app in APPS:
self.django_models[app] = []
models = []
# Load models from each app
for model in apps.get_app_config(app).get_models():
app_label = model._meta.app_label
model_name = model._meta.model_name
if f'{app_label}.{model_name}' not in EXCLUDE_MODELS:
namespace[model.__name__] = model
self.django_models[app].append(model.__name__)
models.append(model.__name__)
self.django_models[app] = sorted(models)
# Constants
try: