Hi! I’m trying to automatically populate my database with a test user if the environment running is DEBUG=True.
It’s supposed to work with the App’s
ready() method but not in my case.
# apps.py from django.apps import AppConfig from django.conf import settings from app.users.models import User class UsersConfig(AppConfig): name = 'app.users' verbose_name = 'Users' def ready(self, *args, **kwargs): if settings.DEBUG: test_email = 'firstname.lastname@example.org' test_password = 'easyTest' u = User.objects.get(email=test_email) if u is None: User.objects.create_user(email=test_email, password=test_password)
When I run the server, I’m getting:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.