module type instances field in list view is always zero #6351

Closed
opened 2025-12-29 19:39:43 +01:00 by adam · 3 comments
Owner

Originally created by @oasys on GitHub (Apr 13, 2022).

NetBox version

v3.9.2

Python version

3.9

Steps to Reproduce

  1. In sidebar, click on "Module Types", Add
  2. Choose any existing manufacturer, enter "test-module-instances" as model, and create
  3. In sidebar, click on "Device Types", Add
  4. Choose any existing manufacturer, enter "test-device" as model, and create
  5. In sidebar, click on "Devices", Add
  6. Choose any existing role, choose "test-device" for device type, choose any existing site, and create
  7. Click "Add Components", "Module Bays", enter "test-bay" for name, and create
  8. Click on "add new module" icon and select "test-modules-instances" module type (created in step 2)
  9. In sidebar, click on Module Types
  10. If "Instances" isn't one of the current table columns, use "Configure Table" to add it

Expected Behavior

The instances field should show a count of the number of instances of this module type. (In this case, "1")

Observed Behavior

The values in the instance column are all zero.

If you select the actual module type (not the list view) to see the information for a single module, the Instances field on that page is correct.

Originally created by @oasys on GitHub (Apr 13, 2022). ### NetBox version v3.9.2 ### Python version 3.9 ### Steps to Reproduce 1. In sidebar, click on "Module Types", Add 2. Choose any existing manufacturer, enter "test-module-instances" as model, and create 3. In sidebar, click on "Device Types", Add 4. Choose any existing manufacturer, enter "test-device" as model, and create 5. In sidebar, click on "Devices", Add 6. Choose any existing role, choose "test-device" for device type, choose any existing site, and create 7. Click "Add Components", "Module Bays", enter "test-bay" for name, and create 8. Click on "add new module" icon and select "test-modules-instances" module type (created in step 2) 9. In sidebar, click on Module Types 10. If "Instances" isn't one of the current table columns, use "Configure Table" to add it ### Expected Behavior The instances field should show a count of the number of instances of this module type. (In this case, "1") ### Observed Behavior The values in the instance column are all zero. If you select the actual module type (not the list view) to see the information for a single module, the Instances field on that page is correct.
adam added the type: bugstatus: duplicate labels 2025-12-29 19:39:43 +01:00
adam closed this issue 2025-12-29 19:39:43 +01:00
Author
Owner

@oasys commented on GitHub (Apr 13, 2022):

Related, I've now managed to get my development installation into a state where going to /dcim/module-types/ raises an exception. My prod installation, which I've updated using the same scripts I used for dev, continues to exhibit the issue as described above.

Traceback (most recent call last):
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
   response = get_response(request)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
   response = wrapped_callback(request, *callback_args, **callback_kwargs)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 84, in view
   return self.dispatch(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 90, in dispatch
   return super().dispatch(request, *args, **kwargs)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 119, in dispatch
   return handler(request, *args, **kwargs)
 File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 185, in get
   table.configure(request)
 File "/opt/netbox/netbox/netbox/tables/tables.py", line 142, in configure
   self.order_by = ordering
 File "/opt/netbox/venv/lib/python3.9/site-packages/django_tables2/tables.py", line 543, in order_by
   self.data.order_by(self._order_by)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django_tables2/data.py", line 226, in order_by
   self.data = self.data.order_by(*order_by_accessors)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/query.py", line 1295, in order_by
   obj.query.add_ordering(*field_names)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 2115, in add_ordering
   self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)
 File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1640, in names_to_path
   raise FieldError(

Exception Type: FieldError at /dcim/module-types/
Exception Value: Cannot resolve keyword 'instance_count' into field. Choices are: comments, consoleporttemplates, consoleserverporttemplates, created, custom_field_data, frontporttemplates, id, images, instances, interfacetemplates, journal_entries, last_updated, manufacturer, manufacturer_id, model, part_number, poweroutlettemplates, powerporttemplates, rearporttemplates, tagged_items, tags
@oasys commented on GitHub (Apr 13, 2022): Related, I've now managed to get my development installation into a state where going to `/dcim/module-types/` raises an exception. My prod installation, which I've updated using the same scripts I used for dev, continues to exhibit the issue as described above. ``` Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 84, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 90, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 119, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 185, in get table.configure(request) File "/opt/netbox/netbox/netbox/tables/tables.py", line 142, in configure self.order_by = ordering File "/opt/netbox/venv/lib/python3.9/site-packages/django_tables2/tables.py", line 543, in order_by self.data.order_by(self._order_by) File "/opt/netbox/venv/lib/python3.9/site-packages/django_tables2/data.py", line 226, in order_by self.data = self.data.order_by(*order_by_accessors) File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/query.py", line 1295, in order_by obj.query.add_ordering(*field_names) File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 2115, in add_ordering self.names_to_path(item.split(LOOKUP_SEP), self.model._meta) File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1640, in names_to_path raise FieldError( Exception Type: FieldError at /dcim/module-types/ Exception Value: Cannot resolve keyword 'instance_count' into field. Choices are: comments, consoleporttemplates, consoleserverporttemplates, created, custom_field_data, frontporttemplates, id, images, instances, interfacetemplates, journal_entries, last_updated, manufacturer, manufacturer_id, model, part_number, poweroutlettemplates, powerporttemplates, rearporttemplates, tagged_items, tags ```
Author
Owner

@jeremystretch commented on GitHub (Apr 13, 2022):

This looks like a duplicate of #9057, which should be fixed in the upcoming v3.2.1 release. Can you confirm?

@jeremystretch commented on GitHub (Apr 13, 2022): This looks like a duplicate of #9057, which should be fixed in the upcoming v3.2.1 release. Can you confirm?
Author
Owner

@oasys commented on GitHub (Apr 14, 2022):

Yes, that looks like it fixes the issue. Apologies for not finding the existing issue before I opened this one.

@oasys commented on GitHub (Apr 14, 2022): Yes, that looks like it fixes the issue. Apologies for not finding the existing issue before I opened this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6351