Ordering of VDC by device gives error "Cannot resolve keyword '_name' into field" #10170

Closed
opened 2025-12-29 21:27:44 +01:00 by adam · 2 comments
Owner

Originally created by @dmulyalin on GitHub (Sep 3, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.0.10

Python Version

3.10

Steps to Reproduce

  1. Got to DCIM -> Virtual Device Contexts
  2. Hit configure table and move "Device" to the right
  3. Sort table by device column - it throws error
  4. Now try going to any device view - throws same error as well

Expected Behavior

Can filter VDC by device

Observed Behavior

Getting this error in the WEB UI:

And this traceback on the cli:

netbox-1               | 10.0.2.2 - - [03/Sep/2024:07:43:29 +0000] "GET /ipam/services/?embedded=True&device_id=7736&return_url=%2Fdcim%2Fdevices%2F7736%2F HTTP/1.1" 200 2949 "http://127.0.0.1:8000/dcim/devices/7736/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
netbox-1               | ::1 - - [03/Sep/2024:07:43:34 +0000] "GET /login/ HTTP/1.1" 200 16656 "-" "curl/8.2.1"
netbox-1               | Internal Server Error: /dcim/virtual-device-contexts/
netbox-1               | Traceback (most recent call last):
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
netbox-1               |     response = get_response(request)
netbox-1               |                ^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
netbox-1               |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
netbox-1               |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
netbox-1               |     return self.dispatch(request, *args, **kwargs)
netbox-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/netbox/netbox/views/generic/base.py", line 77, in dispatch
netbox-1               |     return super().dispatch(request, *args, **kwargs)
netbox-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/netbox/utilities/views.py", line 113, in dispatch
netbox-1               |     return super().dispatch(request, *args, **kwargs)
netbox-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 143, in dispatch
netbox-1               |     return handler(request, *args, **kwargs)
netbox-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 171, in get
netbox-1               |     table = self.get_table(self.queryset, request, has_bulk_actions)
netbox-1               |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/netbox/netbox/views/generic/mixins.py", line 53, in get_table
netbox-1               |     table.configure(request)
netbox-1               |   File "/opt/netbox/netbox/netbox/tables/tables.py", line 165, in configure
netbox-1               |     self.order_by = ordering
netbox-1               |     ^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django_tables2/tables.py", line 542, in order_by
netbox-1               |     self.data.order_by(self._order_by)
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django_tables2/data.py", line 224, in order_by
netbox-1               |     self.data = self.data.order_by(*order_by_accessors)
netbox-1               |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/query.py", line 1701, in order_by
netbox-1               |     obj.query.add_ordering(*field_names)
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2253, in add_ordering
netbox-1               |     self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1772, in names_to_path
netbox-1               |     raise FieldError(
netbox-1               | django.core.exceptions.FieldError: Cannot resolve keyword '_name' into field. Choices are: bookmarks, comments, created, custom_field_data, description, device, device_id, id, identifier, interface_count, interfaces, journal_entries, last_updated, name, primary_ip4, primary_ip4_id, primary_ip6, primary_ip6_id, status, tagged_items, tags, tenant, tenant_id
Originally created by @dmulyalin on GitHub (Sep 3, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.0.10 ### Python Version 3.10 ### Steps to Reproduce 1. Got to DCIM -> Virtual Device Contexts 2. Hit configure table and move "Device" to the right 3. Sort table by device column - it throws error 4. Now try going to any device view - throws same error as well ### Expected Behavior Can filter VDC by device ### Observed Behavior Getting this error in the WEB UI: And this traceback on the cli: ``` netbox-1 | 10.0.2.2 - - [03/Sep/2024:07:43:29 +0000] "GET /ipam/services/?embedded=True&device_id=7736&return_url=%2Fdcim%2Fdevices%2F7736%2F HTTP/1.1" 200 2949 "http://127.0.0.1:8000/dcim/devices/7736/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" netbox-1 | ::1 - - [03/Sep/2024:07:43:34 +0000] "GET /login/ HTTP/1.1" 200 16656 "-" "curl/8.2.1" netbox-1 | Internal Server Error: /dcim/virtual-device-contexts/ netbox-1 | Traceback (most recent call last): netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner netbox-1 | response = get_response(request) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response netbox-1 | response = wrapped_callback(request, *callback_args, **callback_kwargs) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view netbox-1 | return self.dispatch(request, *args, **kwargs) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/netbox/netbox/views/generic/base.py", line 77, in dispatch netbox-1 | return super().dispatch(request, *args, **kwargs) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/netbox/utilities/views.py", line 113, in dispatch netbox-1 | return super().dispatch(request, *args, **kwargs) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 143, in dispatch netbox-1 | return handler(request, *args, **kwargs) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 171, in get netbox-1 | table = self.get_table(self.queryset, request, has_bulk_actions) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/netbox/netbox/views/generic/mixins.py", line 53, in get_table netbox-1 | table.configure(request) netbox-1 | File "/opt/netbox/netbox/netbox/tables/tables.py", line 165, in configure netbox-1 | self.order_by = ordering netbox-1 | ^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django_tables2/tables.py", line 542, in order_by netbox-1 | self.data.order_by(self._order_by) netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django_tables2/data.py", line 224, in order_by netbox-1 | self.data = self.data.order_by(*order_by_accessors) netbox-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/query.py", line 1701, in order_by netbox-1 | obj.query.add_ordering(*field_names) netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2253, in add_ordering netbox-1 | self.names_to_path(item.split(LOOKUP_SEP), self.model._meta) netbox-1 | File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1772, in names_to_path netbox-1 | raise FieldError( netbox-1 | django.core.exceptions.FieldError: Cannot resolve keyword '_name' into field. Choices are: bookmarks, comments, created, custom_field_data, description, device, device_id, id, identifier, interface_count, interfaces, journal_entries, last_updated, name, primary_ip4, primary_ip4_id, primary_ip6, primary_ip6_id, status, tagged_items, tags, tenant, tenant_id ```
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:27:44 +01:00
adam closed this issue 2025-12-29 21:27:45 +01:00
Author
Owner

@dmulyalin commented on GitHub (Sep 3, 2024):

As a work around have to type in the WEB UI:

http://127.0.0.1:8000/dcim/virtual-device-contexts/?sort=name

to revert the sorting, after this error goes away

@dmulyalin commented on GitHub (Sep 3, 2024): As a work around have to type in the WEB UI: ``` http://127.0.0.1:8000/dcim/virtual-device-contexts/?sort=name ``` to revert the sorting, after this error goes away
Author
Owner

@dmulyalin commented on GitHub (Sep 4, 2024):

awesome, thank you for fixing this in so prompt manner @jeremystretch

@dmulyalin commented on GitHub (Sep 4, 2024): awesome, thank you for fixing this in so prompt manner @jeremystretch
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10170