1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

12794 change User ref to get_user_model (#12905)

* 12794 change User ref to get_user_model

* 12794 call get_user_model once in tests

* 12794 call get_user_model once in tests

* 12794 use settings.AUTH_USER_MODEL for FK reference
This commit is contained in:
Arthur Hanson
2023-06-22 05:26:50 -07:00
committed by GitHub
parent bace24b68e
commit 518fd8cca6
34 changed files with 117 additions and 69 deletions

View File

@@ -1,5 +1,5 @@
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import gettext as _
@@ -105,7 +105,7 @@ class JobFilterForm(SavedFiltersMixin, FilterForm):
widget=DateTimePicker()
)
user = DynamicModelMultipleChoiceField(
queryset=User.objects.all(),
queryset=get_user_model().objects.all(),
required=False,
label=_('User'),
widget=APISelectMultiple(

View File

@@ -5,7 +5,7 @@ import sys
from django import get_version
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.core.management.base import BaseCommand
@@ -60,7 +60,7 @@ class Command(BaseCommand):
# Additional objects to include
namespace['ContentType'] = ContentType
namespace['User'] = User
namespace['User'] = get_user_model()
# Load convenience commands
namespace.update({

View File

@@ -1,7 +1,7 @@
import uuid
import django_rq
from django.contrib.auth.models import User
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=User,
to=settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
related_name='+',
blank=True,