-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
Environment
- Python version: 3.7.9 (from docker image python:3.7-alpine)
- NetBox version: 2.9.8 (migrate from 2.6.9)
Steps to Reproduce
- Create a VM.
- Add 2 tags to the VM previously created.
- Go to Config Context tab of this VM.
Expected Behavior
Display config context information.
Observed Behavior
An Error message :
MultipleObjectsReturned at /virtualization/virtual-machines/399/config-context/
get() returned more than one VirtualMachine -- it returned 2!
2 is the number of tag attached to the VM. A vm with 4 tags will return a error message "-- it returned 4!".
Comment
Problem exist with virtual machine and device.
I'm not very confident it is the way to really fix the issue but perhaps it can help :
Problem seems to be in ConfigContextModelQuerySet class. Adding a distinct in queryset of class VirtualMachineConfigContextView fix the error (I don't use config context so i can't test more).
class VirtualMachineConfigContextView(ObjectConfigContextView):
- queryset = VirtualMachine.objects.annotate_config_context_data()
+ queryset = VirtualMachine.objects.distinct().annotate_config_context_data()
base_template = 'virtualization/virtualmachine.html'
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application