Repository: netbox-community/netbox

Issue:
Cannot view device with primary IP assigned - AttributeError: 'NoneType' object has no attribute 'napalm_driver'
### NetBox version

v3.4-beta1

### Python version

3.10

### Steps to Reproduce

1. Create a device testdevice (make sure it has no platform assigned)
2. Create an IP 10.0.0.1/32
3. Assign the IP as primary ipv4 address
4. View the device

### Expected Behavior

Device is shown

### Observed Behavior

```
Traceback (most recent call last):
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/main/devel/repos/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/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/netbox/views/generic/base.py", line 13, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/utilities/views.py", line 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/netbox/views/generic/object_views.py", line 70, in get
    return render(request, self.get_template_name(), {
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/shortcuts.py", line 24, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/backends/django.py", line 62, in render
    return self.template.render(context)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 175, in render
    return self._render(context)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
 ...
    return self.render(context)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/template/library.py", line 258, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "/home/main/devel/repos/netbox/netbox/utilities/templatetags/tabs.py", line 35, in model_view_tabs
    if attrs := tab.render(instance):
  File "/home/main/devel/repos/netbox/netbox/dcim/views.py", line 2075, in render
    instance.platform.napalm_driver
AttributeError: 'NoneType' object has no attribute 'napalm_driver'
```


Discussion:

Resolving patch:
diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -2072,6 +2072,7 @@ def render(self, instance):
         if not (
             instance.status == 'active' and
             instance.primary_ip and
+            instance.platform and
             instance.platform.napalm_driver
         ):
             return None


Test patch: