Console ports created via script not showing in UI #11256

Closed
opened 2025-12-29 21:42:33 +01:00 by adam · 1 comment
Owner

Originally created by @hendrikbl on GitHub (Jun 4, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.3.1

Python Version

3.12

Steps to Reproduce

  1. Create a custom script that instantiates console ports
  2. Create them via ConsolePort.items.bulk_create(items)
  3. Run the script
  4. Inspect the Console Ports List on the UI
  5. Inspect the affected Device on UI

Expected Behavior

The created console ports should be visiblie on the Console Ports list as well as on the Device Details View in the Console Ports tab.

Observed Behavior

The Console Ports appear in the Console Ports list with the correct device linked but the Console Ports tab is missing on the corresponding device view.
When another Console Port is created manually, the tab appears and lists all ports including those created via script while only displaying a 1 on the tab as if there was only one element.

Looks like the console_port_count field does not update when creating objects via scripts. Is there a way to force a reevaluation of the CounterCacheFields after creating objects via script?

Originally created by @hendrikbl on GitHub (Jun 4, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.3.1 ### Python Version 3.12 ### Steps to Reproduce 1. Create a custom script that instantiates console ports 2. Create them via `ConsolePort.items.bulk_create(items)` 3. Run the script 4. Inspect the Console Ports List on the UI 5. Inspect the affected Device on UI ### Expected Behavior The created console ports should be visiblie on the Console Ports list as well as on the Device Details View in the Console Ports tab. ### Observed Behavior The Console Ports appear in the Console Ports list with the correct device linked but the Console Ports tab is missing on the corresponding device view. When another Console Port is created manually, the tab appears and lists all ports including those created via script while only displaying a 1 on the tab as if there was only one element. Looks like the `console_port_count` field does not update when creating objects via scripts. Is there a way to force a reevaluation of the `CounterCacheField`s after creating objects via script?
adam added the type: bug label 2025-12-29 21:42:33 +01:00
adam closed this issue 2025-12-29 21:42:33 +01:00
Author
Owner

@hendrikbl commented on GitHub (Jun 4, 2025):

After some more digging I found this comment with a solution. Seems to be a limitation with django.

@hendrikbl commented on GitHub (Jun 4, 2025): After some more digging I found [this comment](https://github.com/netbox-community/netbox/issues/13937#issuecomment-1743163509) with a solution. Seems to be a limitation with django.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11256