You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user selected device_type and module_type fields together, the page crashes
Expected Behavior
Page should not crash
When I apply the following patch, the page works as expected
diff --git a/netbox/netbox/models/__init__.py b/netbox/netbox/models/__init__.py
index fe25bb837..c0f679e4f 100644
--- a/netbox/netbox/models/__init__.py
+++ b/netbox/netbox/models/__init__.py
@@ -67,8 +67,8 @@ class NetBoxModel(CloningMixin, NetBoxFeatureSet, models.Model):
for field in self._meta.get_fields():
if isinstance(field, GenericForeignKey):
- ct_value = getattr(self, field.ct_field)
- fk_value = getattr(self, field.fk_field)
+ ct_value = getattr(self, field.ct_field, None)
+ fk_value = getattr(self, field.fk_field, None)
if ct_value is None and fk_value is not None:
raise ValidationError({
Observed Behavior
Internal Server Error: /plugins/device-lcm/hardware-notices/add/
Traceback (most recent call last):
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "/home/asaharan/PycharmProjects/netbox/netbox/netbox/views/generic/object_views.py", line 167, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/home/asaharan/PycharmProjects/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/home/asaharan/PycharmProjects/netbox/netbox/utilities/views.py", line 99, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
return handler(request, *args, **kwargs)
File "/home/asaharan/PycharmProjects/netbox/netbox/netbox/views/generic/object_views.py", line 255, in post
if form.is_valid():
File "/home/asaharan/PycharmProjects/netbox/netbox/utilities/forms/mixins.py", line 52, in is_valid
is_valid = super().is_valid()
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 205, in is_valid
return self.is_bound and not self.errors
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 200, in errors
self.full_clean()
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 439, in full_clean
self._post_clean()
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/forms/models.py", line 492, in _post_clean
self.instance.full_clean(exclude=exclude, validate_unique=False)
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1455, in full_clean
self.clean()
File "/home/asaharan/PycharmProjects/netbox/netbox/netbox/models/__init__.py", line 71, in clean
ct_value = getattr(self, field.ct_field)
File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/django/db/models/fields/related_descriptors.py", line 217, in __get__
raise self.RelatedObjectDoesNotExist(
netbox_device_lifecycle_mgmt.models.hardware.HardwareNotice.object_type.RelatedObjectDoesNotExist: HardwareNotice has no object_type.
The text was updated successfully, but these errors were encountered:
NetBox version
v3.5.0-beta2
Python version
3.10
Steps to Reproduce
This is found via a plugin for a form written at https://github.com/Onemind-Services-LLC/netbox-device-lifecycle-mgmt/blob/dev/netbox_device_lifecycle_mgmt/forms/model_forms.py#L31
When a user selected
device_type
andmodule_type
fields together, the page crashesExpected Behavior
Page should not crash
When I apply the following patch, the page works as expected
Observed Behavior
The text was updated successfully, but these errors were encountered: