'NoneType' object has no attribute 'objects' when adding a device to the rack #10689

Closed
opened 2025-12-29 21:34:49 +01:00 by adam · 3 comments
Owner

Originally created by @pvzhitnikov on GitHub (Jan 23, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.2.2

Python Version

3.10

Steps to Reproduce

I can't say exactly at what point the error occurred. Noticed only on version 4.2.2.
An error occurs when connecting a device through a rack

Expected Behavior

Window for adding a device to the rack

Observed Behavior

<class 'AttributeError'>

'NoneType' object has no attribute 'objects'

Python version: 3.10.12
NetBox Version: 4.2.0
Plugins: Nothing installed

Internal Server Error: /dcim/devices/add/
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/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 "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 182, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 233, in get
    form = self.form(instance=obj, initial=initial_data)
  File "/opt/netbox/netbox/dcim/forms/model_forms.py", line 581, in __init__
    super().__init__(*args, **kwargs)
  File "/opt/netbox/netbox/netbox/forms/mixins.py", line 31, in __init__
    self._append_customfield_fields()
  File "/opt/netbox/netbox/netbox/forms/mixins.py", line 57, in _append_customfield_fields
    self.fields[field_name] = self._get_form_field(customfield)
  File "/opt/netbox/netbox/netbox/forms/base.py", line 47, in _get_form_field
    return customfield.to_form_field()
  File "/opt/netbox/netbox/extras/models/customfields.py", line 529, in to_form_field
    'queryset': model.objects.all(),
AttributeError: 'NoneType' object has no attribute 'objects'
Originally created by @pvzhitnikov on GitHub (Jan 23, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.2.2 ### Python Version 3.10 ### Steps to Reproduce I can't say exactly at what point the error occurred. Noticed only on version 4.2.2. An error occurs when connecting a device through a rack ### Expected Behavior Window for adding a device to the rack ### Observed Behavior <class 'AttributeError'> 'NoneType' object has no attribute 'objects' Python version: 3.10.12 NetBox Version: 4.2.0 Plugins: Nothing installed ``` Internal Server Error: /dcim/devices/add/ Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/opt/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 "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 182, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 233, in get form = self.form(instance=obj, initial=initial_data) File "/opt/netbox/netbox/dcim/forms/model_forms.py", line 581, in __init__ super().__init__(*args, **kwargs) File "/opt/netbox/netbox/netbox/forms/mixins.py", line 31, in __init__ self._append_customfield_fields() File "/opt/netbox/netbox/netbox/forms/mixins.py", line 57, in _append_customfield_fields self.fields[field_name] = self._get_form_field(customfield) File "/opt/netbox/netbox/netbox/forms/base.py", line 47, in _get_form_field return customfield.to_form_field() File "/opt/netbox/netbox/extras/models/customfields.py", line 529, in to_form_field 'queryset': model.objects.all(), AttributeError: 'NoneType' object has no attribute 'objects' ```
adam closed this issue 2025-12-29 21:34:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 23, 2025):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@jeremystretch commented on GitHub (Jan 23, 2025): Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@bctiemann commented on GitHub (Jan 24, 2025):

@pvzhitnikov Specifically it looks like this error is occurring in the Custom Fields handling code. Please provide information about what custom fields you have defined.

Also, please clarify what you mean by "when connecting a device through a rack". What UI workflow are you using? Please provide step-by-step reproduction instructions.

@bctiemann commented on GitHub (Jan 24, 2025): @pvzhitnikov Specifically it looks like this error is occurring in the Custom Fields handling code. Please provide information about what custom fields you have defined. Also, please clarify what you mean by "when connecting a device through a rack". What UI workflow are you using? Please provide step-by-step reproduction instructions.
Author
Owner

@pvzhitnikov commented on GitHub (Jan 24, 2025):

Thanks for the answers. We managed to solve the problem. Custom fields were created by the IP Fabric plugin

@pvzhitnikov commented on GitHub (Jan 24, 2025): Thanks for the answers. We managed to solve the problem. Custom fields were created by the IP Fabric plugin
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10689