Device has no device_type when importing csv of devices #1989

Closed
opened 2025-12-29 17:21:11 +01:00 by adam · 8 comments
Owner

Originally created by @mrintegrity on GitHub (Sep 4, 2018).

Environment

  • Python version: 2.7.12
  • NetBox version: 2.4.4

Steps to Reproduce

Import a CSV with an unknown device type

Expected Behavior

An error showing the line in the csv which contains an unknown device type

Observed Behavior

Exception thrown:
<class 'django.db.models.fields.related_descriptors.RelatedObjectDoesNotExist'>

Device has no device_type.

This appears to be the same as issue #678

Originally created by @mrintegrity on GitHub (Sep 4, 2018). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 2.7.12 * NetBox version: 2.4.4 <!-- Describe in detail the steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). --> ### Steps to Reproduce Import a CSV with an unknown device type <!-- What did you expect to happen? --> ### Expected Behavior An error showing the line in the csv which contains an unknown device type <!-- What happened instead? --> ### Observed Behavior > Exception thrown: > <class 'django.db.models.fields.related_descriptors.RelatedObjectDoesNotExist'> > > Device has no device_type. This appears to be the same as issue #678
adam closed this issue 2025-12-29 17:21:11 +01:00
Author
Owner

@mrintegrity commented on GitHub (Sep 4, 2018):

device_role,manufacturer,asset_tag,rack_name,face,position,model_name,site,status
Storage,HP,,rack2,Front,5,Storageworks P2000 G3,TRA,Active
Storage,HP,hwid058,rack2,Front,21,Storageworks P2000 G3,TRA,Active
Server,HP,hwid132,rack2,Front,23,DL360G7,TRA,Active
Server,HP,hwid136,rack2,Front,25,DL360G7,TRA,Active
Blade Chassis,HP,,rack2,Front,9,DL2000G6,TRA,Active
Blade Chassis,HP,,rack2,Front,15,DL2000G6,TRA,Active
Blade Chassis,HP,,rack2,Front,17,DL2000G6,TRA,Active
Blade Chassis,HP,,rack2,Front,19,DL2000G6,TRA,Active
Server,HP,hwid103,rack2,Front,1,DL180G6,TRA,Active
Server,HP,hwid104,rack2,Front,3,DL180G6,TRA,Active
Server,HP,hwid203,rack2,Front,13,DL180G6,TRA,Active
Server,HP,hwid385,rack2,Front,30,DL165G7,TRA,Active
Internal Switch,Cisco,hwid146,rack2,Rear,39,Catalyst 4948E-F,TRA,Active
Internal Switch,Cisco,hwid144,rack2,Rear,36,Catalyst 4948,TRA,Active
Internal Switch,Cisco,hwid145,rack2,Rear,37,Catalyst 4948,TRA,Active
Internal Switch,Cisco,,rack2,Rear,33,Catalyst 2960-S,TRA,Active
Router,Cisco,hwid148 / hwid069,rack2,Rear,41,ASR1002-F,TRA,Active
VPN,Cisco,hwid355,rack2,Rear,31,ASA5512-X,TRA,Active
Storage,45drives.com,hwid469,rack2,Front,26,45drives.com,TRA,Active
Router,Cisco,hwid143,rack2,Rear,34,1900 Series,TRA,Active
Storage,Dell,,rack2,Front,11,,TRA,Active
Server,SuperMicro,,rack2,Front,24,,TRA,Active
Blade Server,HP,hwid027,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid028,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid029,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid030,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid117,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid336,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid119,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid120,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid121,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid122,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid123,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid124,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid125,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid126,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid127,rack2,Front,,DL170EG6,TRA,Active
Blade Server,HP,hwid128,rack2,Front,,DL170EG6,TRA,Active
@mrintegrity commented on GitHub (Sep 4, 2018): ``` device_role,manufacturer,asset_tag,rack_name,face,position,model_name,site,status Storage,HP,,rack2,Front,5,Storageworks P2000 G3,TRA,Active Storage,HP,hwid058,rack2,Front,21,Storageworks P2000 G3,TRA,Active Server,HP,hwid132,rack2,Front,23,DL360G7,TRA,Active Server,HP,hwid136,rack2,Front,25,DL360G7,TRA,Active Blade Chassis,HP,,rack2,Front,9,DL2000G6,TRA,Active Blade Chassis,HP,,rack2,Front,15,DL2000G6,TRA,Active Blade Chassis,HP,,rack2,Front,17,DL2000G6,TRA,Active Blade Chassis,HP,,rack2,Front,19,DL2000G6,TRA,Active Server,HP,hwid103,rack2,Front,1,DL180G6,TRA,Active Server,HP,hwid104,rack2,Front,3,DL180G6,TRA,Active Server,HP,hwid203,rack2,Front,13,DL180G6,TRA,Active Server,HP,hwid385,rack2,Front,30,DL165G7,TRA,Active Internal Switch,Cisco,hwid146,rack2,Rear,39,Catalyst 4948E-F,TRA,Active Internal Switch,Cisco,hwid144,rack2,Rear,36,Catalyst 4948,TRA,Active Internal Switch,Cisco,hwid145,rack2,Rear,37,Catalyst 4948,TRA,Active Internal Switch,Cisco,,rack2,Rear,33,Catalyst 2960-S,TRA,Active Router,Cisco,hwid148 / hwid069,rack2,Rear,41,ASR1002-F,TRA,Active VPN,Cisco,hwid355,rack2,Rear,31,ASA5512-X,TRA,Active Storage,45drives.com,hwid469,rack2,Front,26,45drives.com,TRA,Active Router,Cisco,hwid143,rack2,Rear,34,1900 Series,TRA,Active Storage,Dell,,rack2,Front,11,,TRA,Active Server,SuperMicro,,rack2,Front,24,,TRA,Active Blade Server,HP,hwid027,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid028,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid029,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid030,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid117,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid336,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid119,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid120,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid121,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid122,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid123,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid124,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid125,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid126,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid127,rack2,Front,,DL170EG6,TRA,Active Blade Server,HP,hwid128,rack2,Front,,DL170EG6,TRA,Active ```
Author
Owner

@mrintegrity commented on GitHub (Sep 4, 2018):

Is there somewhere I can privately share more extensive debug information?

@mrintegrity commented on GitHub (Sep 4, 2018): Is there somewhere I can privately share more extensive debug information?
Author
Owner

@jeremystretch commented on GitHub (Sep 5, 2018):

Please post the exact steps needed to recreate this error, beginning with the creation of the device type(s). The full stack trace would also be helpful.

@jeremystretch commented on GitHub (Sep 5, 2018): Please post the exact steps needed to recreate this error, beginning with the creation of the device type(s). The full stack trace would also be helpful.
Author
Owner

@jeremystretch commented on GitHub (Sep 13, 2018):

Closing due to lack of activity.

@jeremystretch commented on GitHub (Sep 13, 2018): Closing due to lack of activity.
Author
Owner

@mrintegrity commented on GitHub (Sep 14, 2018):

It is quite simple to reproduce, create a rack, manufacturer, device role, site and try to import the following device:

ast733,Blade Chassis,SuperMicro,ast733,rack3,Front,25,,STH,Active

Note that the third last column (model_name) is empty, this causes an exception

@mrintegrity commented on GitHub (Sep 14, 2018): It is quite simple to reproduce, create a rack, manufacturer, device role, site and try to import the following device: ast733,Blade Chassis,SuperMicro,ast733,rack3,Front,25,,STH,Active Note that the third last column (model_name) is empty, this causes an exception
Author
Owner

@mrintegrity commented on GitHub (Sep 27, 2018):

@jeremystretch here is the traceback, sorry for the delay in getting it:

Internal Server Error: /dcim/devices/import/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/mixins.py", line 92, in dispatch
    return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox-2.4.4/netbox/utilities/views.py", line 439, in post
    if obj_form.is_valid():
  File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py", line 183, in is_valid
    return self.is_bound and not self.errors
  File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py", line 386, in full_clean
    self._post_clean()
  File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 413, in _post_clean
    self.instance.full_clean(exclude=exclude, validate_unique=False)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 1234, in full_clean
    self.clean()
  File "/opt/netbox-2.4.4/netbox/dcim/models.py", line 1341, in clean
    if self.position and self.device_type.u_height == 0:
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related_descriptors.py", line 194, in __get__
    "%s has no %s." % (self.field.model.__name__, self.field.name)
RelatedObjectDoesNotExist: Device has no device_type.

@mrintegrity commented on GitHub (Sep 27, 2018): @jeremystretch here is the traceback, sorry for the delay in getting it: ``` Internal Server Error: /dcim/devices/import/ Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/mixins.py", line 92, in dispatch return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 88, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox-2.4.4/netbox/utilities/views.py", line 439, in post if obj_form.is_valid(): File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py", line 183, in is_valid return self.is_bound and not self.errors File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py", line 175, in errors self.full_clean() File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py", line 386, in full_clean self._post_clean() File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 413, in _post_clean self.instance.full_clean(exclude=exclude, validate_unique=False) File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 1234, in full_clean self.clean() File "/opt/netbox-2.4.4/netbox/dcim/models.py", line 1341, in clean if self.position and self.device_type.u_height == 0: File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related_descriptors.py", line 194, in __get__ "%s has no %s." % (self.field.model.__name__, self.field.name) RelatedObjectDoesNotExist: Device has no device_type. ```
Author
Owner

@dal00 commented on GitHub (Oct 10, 2018):

This is sitll an issue. Please reopen the ticket.

@dal00 commented on GitHub (Oct 10, 2018): This is sitll an issue. Please reopen the ticket.
Author
Owner

@DanSheps commented on GitHub (Oct 10, 2018):

Model Name (Device Type) is a required field, I am unsure of what you are looking to get...

@DanSheps commented on GitHub (Oct 10, 2018): Model Name (Device Type) is a required field, I am unsure of what you are looking to get...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1989