Skip to content

Commit 23b8a50

Browse files
committed
fix: prevent database queries on unmanaged ClientCredentials model
Signed-off-by: Michal Fiedorowicz <mfiedorowicz@netboxlabs.com>
1 parent e3a9d0e commit 23b8a50

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ at [https://netboxlabs.com/blog/introducing-diode-streamlining-data-ingestion-in
2020
| >= 4.2.3 | 1.1.0 |
2121
| >= 4.2.3 | 1.2.0 |
2222
| >= 4.4.0 | 1.4.0 |
23+
| >= 4.4.0 | 1.4.1 |
2324

2425
## Installation
2526

docker/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: diode-netbox-plugin
22
services:
33
netbox: &netbox
4-
image: netboxcommunity/netbox:v4.3.3-3.3.0-diode-netbox-plugin
4+
image: netboxcommunity/netbox:v4.4.2-3.4.1-diode-netbox-plugin
55
build:
66
context: .
77
dockerfile: Dockerfile-diode-netbox-plugin

netbox_diode_plugin/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,19 @@ def get_absolute_url(self):
4141
return reverse("plugins:netbox_diode_plugin:settings")
4242

4343

44+
class UnmanagedModelManager(models.Manager):
45+
"""Manager for unmanaged models that prevents database queries."""
46+
47+
def get_queryset(self):
48+
"""Return an empty queryset without hitting the database."""
49+
return super().get_queryset().none()
50+
51+
4452
class ClientCredentials(models.Model):
4553
"""Dummy model to allow for permissions, saved filters, etc.."""
4654

55+
objects = UnmanagedModelManager()
56+
4757
class Meta:
4858
"""Meta class."""
4959

0 commit comments

Comments
 (0)