Skip to content

Commit

Permalink
Closes #17482: Ignore Branch & StagedChange in nbshell
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Sep 12, 2024
1 parent 0e34fba commit f636af9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions netbox/core/management/commands/nbshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
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}
Expand Down Expand Up @@ -44,12 +48,16 @@ def get_namespace(self):

# 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():
namespace[model.__name__] = model
self.django_models[app].append(model.__name__)
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
models.append(model.__name__)
self.django_models[app] = sorted(models)

# Constants
try:
Expand Down

0 comments on commit f636af9

Please sign in to comment.