From a0bfada31f920c53a0387c9159b03ff6c2f9e8de Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 15 Jun 2023 14:26:02 -0700 Subject: [PATCH] 12794 use settings.AUTH_USER_MODEL for FK reference --- netbox/core/models/jobs.py | 4 ++-- netbox/dcim/models/racks.py | 4 ++-- netbox/extras/models/change_logging.py | 4 ++-- netbox/extras/models/models.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/netbox/core/models/jobs.py b/netbox/core/models/jobs.py index 0715a4521..9be06bd6d 100644 --- a/netbox/core/models/jobs.py +++ b/netbox/core/models/jobs.py @@ -1,7 +1,7 @@ import uuid import django_rq -from django.contrib.auth import get_user_model +from django.conf import settings from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.core.validators import MinValueValidator @@ -69,7 +69,7 @@ class Job(models.Model): blank=True ) user = models.ForeignKey( - to=get_user_model(), + to=settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', blank=True, diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index 777454dce..7b6039c5d 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -1,7 +1,7 @@ import decimal from functools import cached_property -from django.contrib.auth import get_user_model +from django.conf import settings from django.contrib.contenttypes.fields import GenericRelation from django.contrib.postgres.fields import ArrayField from django.core.exceptions import ValidationError @@ -505,7 +505,7 @@ class RackReservation(PrimaryModel): null=True ) user = models.ForeignKey( - to=get_user_model(), + to=settings.AUTH_USER_MODEL, on_delete=models.PROTECT ) description = models.CharField( diff --git a/netbox/extras/models/change_logging.py b/netbox/extras/models/change_logging.py index b03ebf475..54d72cdd8 100644 --- a/netbox/extras/models/change_logging.py +++ b/netbox/extras/models/change_logging.py @@ -1,4 +1,4 @@ -from django.contrib.auth import get_user_model +from django.conf import settings from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models @@ -24,7 +24,7 @@ class ObjectChange(models.Model): db_index=True ) user = models.ForeignKey( - to=get_user_model(), + to=settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='changes', blank=True, diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index bfb13fc71..5778c184e 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -3,7 +3,7 @@ import urllib.parse from django.conf import settings from django.contrib import admin -from django.contrib.auth import get_user_model +from django.conf import settings from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.core.cache import cache @@ -419,7 +419,7 @@ class SavedFilter(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel): blank=True ) user = models.ForeignKey( - to=get_user_model(), + to=settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, blank=True, null=True @@ -560,7 +560,7 @@ class JournalEntry(CustomFieldsMixin, CustomLinksMixin, TagsMixin, ExportTemplat fk_field='assigned_object_id' ) created_by = models.ForeignKey( - to=get_user_model(), + to=settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, blank=True, null=True