Problem after upgrade from 4.1.14 to 4.1.15 and 4.1.16 - "AttributeError at /dcim/sites/" #10429

Closed
opened 2025-12-29 21:31:21 +01:00 by adam · 5 comments
Owner

Originally created by @arcanjobr on GitHub (Oct 31, 2024).

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.16

Python Version

3.10

Steps to Reproduce

The error appear when you:

  1. Expand "Organization" then
  2. click in "Sites".

AttributeError at /dcim/sites/
'NoneType' object has no attribute 'objects'
Request Method: GET
Request URL: https://192.168.10.11/dcim/sites/
Django Version: 5.0.9
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'objects'
Exception Location: /opt/netbox/netbox/extras/models/customfields.py, line 529, in to_form_field
Raised during: dcim.views.SiteListView
Python Executable: /opt/netbox/venv/bin/python3
Python Version: 3.10.12
Python Path:
['/opt/netbox/netbox',
'/opt/netbox',
'/opt/netbox/venv/bin',
'/usr/lib/python310.zip',
'/usr/lib/python3.10',
'/usr/lib/python3.10/lib-dynload',
'/opt/netbox/venv/lib/python3.10/site-packages']
Server time: Thu, 31 Oct 2024 15:26:24 -0300

Expected Behavior

The "sites" section appear to fillout

Observed Behavior

The system crash and show this error (Debug=True):

Environment:

Request Method: GET
Request URL: https://192.168.10.11/dcim/sites/

Django Version: 5.0.9
Python Version: 3.10.12
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.forms',
'corsheaders',
'debug_toolbar',
'django_filters',
'django_htmx',
'django_tables2',
'django_prometheus',
'strawberry_django',
'mptt',
'rest_framework',
'social_django',
'taggit',
'timezone_field',
'core',
'account',
'circuits',
'dcim',
'ipam',
'extras',
'tenancy',
'users',
'utilities',
'virtualization',
'vpn',
'wireless',
'django_rq',
'drf_spectacular',
'drf_spectacular_sidecar']
Installed Middleware:
['strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django_htmx.middleware.HtmxMiddleware',
'netbox.middleware.RemoteUserMiddleware',
'netbox.middleware.CoreMiddleware',
'netbox.middleware.MaintenanceModeMiddleware']

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/base.py", line 77, 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/bulk_views.py", line 190, in get
'filter_form': self.filterset_form(request.GET) if self.filterset_form else None,
File "/opt/netbox/netbox/netbox/forms/base.py", line 173, 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 188, in _get_form_field
return customfield.to_form_field(set_initial=False, enforce_required=False, enforce_visibility=False)
File "/opt/netbox/netbox/extras/models/customfields.py", line 529, in to_form_field
'queryset': model.objects.all(),

Exception Type: AttributeError at /dcim/sites/
Exception Value: 'NoneType' object has no attribute 'objects'

Originally created by @arcanjobr on GitHub (Oct 31, 2024). ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.16 ### Python Version 3.10 ### Steps to Reproduce The error appear when you: 1. Expand "Organization" then 2. click in "Sites". AttributeError at /dcim/sites/ 'NoneType' object has no attribute 'objects' Request Method: GET Request URL: https://192.168.10.11/dcim/sites/ Django Version: 5.0.9 Exception Type: AttributeError Exception Value: 'NoneType' object has no attribute 'objects' Exception Location: /opt/netbox/netbox/extras/models/customfields.py, line 529, in to_form_field Raised during: dcim.views.SiteListView Python Executable: /opt/netbox/venv/bin/python3 Python Version: 3.10.12 Python Path: ['/opt/netbox/netbox', '/opt/netbox', '/opt/netbox/venv/bin', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/opt/netbox/venv/lib/python3.10/site-packages'] Server time: Thu, 31 Oct 2024 15:26:24 -0300 ### Expected Behavior The "sites" section appear to fillout ### Observed Behavior The system crash and show this error (Debug=True): Environment: Request Method: GET Request URL: https://192.168.10.11/dcim/sites/ Django Version: 5.0.9 Python Version: 3.10.12 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.forms', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_htmx', 'django_tables2', 'django_prometheus', 'strawberry_django', 'mptt', 'rest_framework', 'social_django', 'taggit', 'timezone_field', 'core', 'account', 'circuits', 'dcim', 'ipam', 'extras', 'tenancy', 'users', 'utilities', 'virtualization', 'vpn', 'wireless', 'django_rq', 'drf_spectacular', 'drf_spectacular_sidecar'] Installed Middleware: ['strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django_htmx.middleware.HtmxMiddleware', 'netbox.middleware.RemoteUserMiddleware', 'netbox.middleware.CoreMiddleware', 'netbox.middleware.MaintenanceModeMiddleware'] 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/base.py", line 77, 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/bulk_views.py", line 190, in get 'filter_form': self.filterset_form(request.GET) if self.filterset_form else None, File "/opt/netbox/netbox/netbox/forms/base.py", line 173, 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 188, in _get_form_field return customfield.to_form_field(set_initial=False, enforce_required=False, enforce_visibility=False) File "/opt/netbox/netbox/extras/models/customfields.py", line 529, in to_form_field 'queryset': model.objects.all(), Exception Type: AttributeError at /dcim/sites/ Exception Value: 'NoneType' object has no attribute 'objects'
adam added the netbox label 2025-12-29 21:31:21 +01:00
adam closed this issue 2025-12-29 21:31:22 +01:00
Author
Owner

@arthanson commented on GitHub (Oct 31, 2024):

@arcanjobr I just tried this and it works fine on my install. It looks like you might be using custom fields? Do you have one defined for your Sites? Do the other models open fine for you?

@arthanson commented on GitHub (Oct 31, 2024): @arcanjobr I just tried this and it works fine on my install. It looks like you might be using custom fields? Do you have one defined for your Sites? Do the other models open fine for you?
Author
Owner

@arcanjobr commented on GitHub (Oct 31, 2024):

Hello @arthanson, i do not remember to create any custom field, maybe any plugin did. I've deactived all plugins before update to 4.1.15. Is there any way to remove custom fields without accessing 'Sites' ?

@arcanjobr commented on GitHub (Oct 31, 2024): Hello @arthanson, i do not remember to create any custom field, maybe any plugin did. I've deactived all plugins before update to 4.1.15. Is there any way to remove custom fields without accessing 'Sites' ?
Author
Owner

@arcanjobr commented on GitHub (Oct 31, 2024):

You are right, found it, i was using IP Fabric plugin before update. Probably i'll need wait till IP Fabric get updata also

Variable Value
enforce_required False
enforce_visibility False
field_class <class 'utilities.forms.fields.dynamic.DynamicModelChoiceField'>
for_csv_import False
initial None
model None
required False
self <CustomField: IP Fabric Last Sync>
set_initial False

@arcanjobr commented on GitHub (Oct 31, 2024): You are right, found it, i was using IP Fabric plugin before update. Probably i'll need wait till IP Fabric get updata also Variable Value enforce_required False enforce_visibility False field_class <class 'utilities.forms.fields.dynamic.DynamicModelChoiceField'> for_csv_import False initial None model None required False self <CustomField: **IP Fabric Last Sync**> set_initial False
Author
Owner

@arcanjobr commented on GitHub (Oct 31, 2024):

Just re-installed the plugin and followed steps. Working fine now.

@arcanjobr commented on GitHub (Oct 31, 2024): Just re-installed the plugin and followed steps. Working fine now.
Author
Owner

@arcanjobr commented on GitHub (Oct 31, 2024):

After reinstalled the plugin whom created the Custom Field, the Netbox is working again.

@arcanjobr commented on GitHub (Oct 31, 2024): After reinstalled the plugin whom created the Custom Field, the Netbox is working again.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10429