diff --git a/catalog/models.py b/catalog/models.py index f0b461f3..56b45f75 100644 --- a/catalog/models.py +++ b/catalog/models.py @@ -64,7 +64,7 @@ def __str__(self): import uuid # Required for unique book instances from datetime import date -from django.contrib.auth.models import User # Required to assign User as a borrower +from django.conf import settings # Required to assign User as a borrower class BookInstance(models.Model): @@ -74,7 +74,7 @@ class BookInstance(models.Model): book = models.ForeignKey('Book', on_delete=models.RESTRICT, null=True) imprint = models.CharField(max_length=200) due_back = models.DateField(null=True, blank=True) - borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) + borrower = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True) @property def is_overdue(self): diff --git a/catalog/tests/test_views.py b/catalog/tests/test_views.py index 72ce5aba..fc7e17b3 100644 --- a/catalog/tests/test_views.py +++ b/catalog/tests/test_views.py @@ -50,8 +50,10 @@ def test_lists_all_authors(self): from django.utils import timezone from catalog.models import BookInstance, Book, Genre, Language -from django.contrib.auth.models import User # Required to assign User as a borrower +# Get user model from settings +from django.contrib.auth import get_user_model +User = get_user_model() class LoanedBookInstancesByUserListViewTest(TestCase):