I'm using django's AbstractUser
to create my custom user along with my custom manager that extends BaseUserManager
. But I didn't add any extra fields to it yet. So it looks like this:
# mypoject/apps/accounts/models.py
from django.contrib.auth.models import AbstractUser
from myproject.apps.accounts.managers import UserManager
class User(AbstractUser):
objects = UserManager
And I wrote a unit test for it, and it looks like this:
# myproject/apps/accounts/tests/test_models.py
from unittest import TestCase
class UserTests(TestCase):
def test_create_user(self):
from myproject.apps.accounts.models import User
user = User.objects.create_user(username='mock_user')
self.assertIsInstance(user)
But when I run the test, I get this error message:
RuntimeError: Model class myproject.apps.accounts.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
PS: My accounts app is in INSTALLED_APPS
array and works fine.