Custom Field Bulk Import gives "'NoneType' object has no attribute 'app_label'" #8443

Closed
opened 2025-12-29 20:36:46 +01:00 by adam · 2 comments
Owner

Originally created by @arjanhak on GitHub (Aug 10, 2023).

NetBox version

v3.5.7

Python version

3.8

Steps to Reproduce

  1. create a new custom field in a fresh NetBox install
  2. export all custom fields in format "All Data (CSV)"
  3. edit the CSV and rename the field to make it unique (or vice versa, rename the current custom field in the browser)
  4. Navigate browser to /extras/custom-fields/import/#tab_upload-form
  5. Choose the CSV file
  6. press Submit

Initially I tried importing the custom fields exported from a NetBox 3.5.5 instance, but these seem to be the easiest steps to reproduce

Expected Behavior

The custom fields have been imported successfully

Observed Behavior

The Gui shows a Server Error:

<class 'AttributeError'>

'NoneType' object has no attribute 'app_label'

Python version: 3.8.12
NetBox version: 3.5.7

The application log contains:

Internal Server Error: /extras/custom-fields/import/
Traceback (most recent call last):
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 103, 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 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 449, in post
    new_objs = self.create_and_update_objects(form, request)
  File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 407, in create_and_update_objects
    if model_form.is_valid():
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 205, in is_valid
    return self.is_bound and not self.errors
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 200, in errors
    self.full_clean()
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 437, in full_clean
    self._clean_fields()
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 449, in _clean_fields
    value = field.clean(value)
  File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/models.py", line 1586, in clean
    value = self.prepare_value(value)
  File "/opt/netbox/netbox/utilities/forms/fields/csv.py", line 117, in prepare_value
    return content_type_identifier(value)
  File "/opt/netbox/netbox/utilities/utils.py", line 464, in content_type_identifier
    return f'{ct.app_label}.{ct.model}'
AttributeError: 'NoneType' object has no attribute 'app_label'
Originally created by @arjanhak on GitHub (Aug 10, 2023). ### NetBox version v3.5.7 ### Python version 3.8 ### Steps to Reproduce 1. create a new custom field in a fresh NetBox install 2. export all custom fields in format "All Data (CSV)" 3. edit the CSV and rename the field to make it unique (or vice versa, rename the current custom field in the browser) 4. Navigate browser to /extras/custom-fields/import/#tab_upload-form 5. Choose the CSV file 6. press Submit Initially I tried importing the custom fields exported from a NetBox 3.5.5 instance, but these seem to be the easiest steps to reproduce ### Expected Behavior The custom fields have been imported successfully ### Observed Behavior The Gui shows a Server Error: ``` <class 'AttributeError'> 'NoneType' object has no attribute 'app_label' Python version: 3.8.12 NetBox version: 3.5.7 ``` The application log contains: ``` Internal Server Error: /extras/custom-fields/import/ Traceback (most recent call last): File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner response = get_response(request) File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 103, 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 99, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 142, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 449, in post new_objs = self.create_and_update_objects(form, request) File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 407, in create_and_update_objects if model_form.is_valid(): File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 205, in is_valid return self.is_bound and not self.errors File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 200, in errors self.full_clean() File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 437, in full_clean self._clean_fields() File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/forms.py", line 449, in _clean_fields value = field.clean(value) File "/opt/netbox-3.5.7/venv/lib64/python3.8/site-packages/django/forms/models.py", line 1586, in clean value = self.prepare_value(value) File "/opt/netbox/netbox/utilities/forms/fields/csv.py", line 117, in prepare_value return content_type_identifier(value) File "/opt/netbox/netbox/utilities/utils.py", line 464, in content_type_identifier return f'{ct.app_label}.{ct.model}' AttributeError: 'NoneType' object has no attribute 'app_label' ```
adam closed this issue 2025-12-29 20:36:46 +01:00
Author
Owner

@arjanhak commented on GitHub (Aug 10, 2023):

I used this CSV file:
netbox_custom fields (3).csv

@arjanhak commented on GitHub (Aug 10, 2023): I used this CSV file: [netbox_custom fields (3).csv](https://github.com/netbox-community/netbox/files/12312748/netbox_custom.fields.3.csv)
Author
Owner

@kkthxbye-code commented on GitHub (Aug 10, 2023):

Your column names are wrong. Please see the wiki:

https://github.com/netbox-community/netbox/wiki/Frequently-Asked-Questions#why-cant-i-pass-exported-data-directly-into-the-import-form

You can see the correct column names below the import form.

@kkthxbye-code commented on GitHub (Aug 10, 2023): Your column names are wrong. Please see the wiki: https://github.com/netbox-community/netbox/wiki/Frequently-Asked-Questions#why-cant-i-pass-exported-data-directly-into-the-import-form You can see the correct column names below the import form.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8443