Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server error with certain dashboard widgets after upgrading to v4.0 #15815

Closed
julianstolp opened this issue Apr 23, 2024 · 1 comment
Closed
Assignees
Labels
beta Concerns a bug/feature in a beta release severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@julianstolp
Copy link

julianstolp commented Apr 23, 2024

Deployment Type

Self-hosted

NetBox Version

v4.0-beta2

Python Version

3.10

Steps to Reproduce

  1. Add Widget Object Count with Models Users > Group, Users > User in v3.7.5
  2. Upgrade to v4.0-beta2
  3. Restart NetBox
  4. Go to https://netbox-url/

Most likley caused by #15304

Expected Behavior

Dashboard view loads as usual.

Observed Behavior

Server Error

Environment:


Request Method: GET
Request URL: https://netbox-url/

Django Version: 5.0.4
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',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 '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',
 'django_prometheus.middleware.PrometheusAfterMiddleware']


Template error:
In template /opt/netbox/netbox/templates/extras/dashboard/widget.html, error at line 36
   ObjectType matching query does not exist.
   26 :       <a href="#"
   27 :         hx-get="{% url 'extras:dashboardwidget_delete' id=widget.id %}"
   28 :         hx-target="#htmx-modal-content"
   29 :         data-bs-toggle="modal"
   30 :         data-bs-target="#htmx-modal"
   31 :       >
   32 :         <i class="mdi mdi-close text-{{ widget.fg_color }}"></i>
   33 :       </a>
   34 :     </div>
   35 :     <div class="card-body p-2 pt-1 overflow-auto">
   36 :        {% render_widget widget %} 
   37 :     </div>
   38 :   </div>
   39 : </div>
   40 : 

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 20, in get_by_natural_key
    ct = self._cache[self.db][(app_label, model)]

During handling of the above exception (('users', 'netboxgroup')), another exception occurred:
  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/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/misc.py", line 59, in get
    return render(request, self.template_name, {
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/shortcuts.py", line 25, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 159, in render
    return compiled_parent._render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 159, in render
    return compiled_parent._render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/defaulttags.py", line 242, in render
    nodelist.append(node.render_annotated(context))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 210, in render
    return template.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 173, in render
    return self._render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/library.py", line 237, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/opt/netbox/netbox/extras/templatetags/dashboard.py", line 11, in render_widget
    return widget.render(request)
  File "/opt/netbox/netbox/extras/dashboard/widgets.py", line 189, in render
    for model in get_models_from_content_types(self.config['models']):
  File "/opt/netbox/netbox/extras/dashboard/widgets.py", line 57, in get_models_from_content_types
    content_type = ObjectType.objects.get_by_natural_key(app_label, model_name)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 22, in get_by_natural_key
    ct = self.get(app_label=app_label, model=model)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 649, in get
    raise self.model.DoesNotExist(

Exception Type: DoesNotExist at /
Exception Value: ObjectType matching query does not exist.

image

@julianstolp julianstolp added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Apr 23, 2024
@jeremystretch jeremystretch added the beta Concerns a bug/feature in a beta release label Apr 23, 2024
@jeffgdotorg jeffgdotorg removed their assignment Apr 23, 2024
@jeffgdotorg jeffgdotorg removed the status: needs triage This issue is awaiting triage by a maintainer label Apr 23, 2024
@jeffgdotorg
Copy link
Contributor

Thanks for your report. Problem behavior reproduced.

@jeffgdotorg jeffgdotorg added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows labels Apr 23, 2024
@arthanson arthanson self-assigned this Apr 24, 2024
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Apr 24, 2024
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Apr 25, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

4 participants