我想在 setting.py 中为django-push-notifications中的 PUSH_NOTIFICATIONS_SETTINGS 导入应用程序模型。这是我的代码:
INSTALLED_APPS = (
....
'my_app',
'push_notifications'
....
)
from my_app.models import User
PUSH_NOTIFICATIONS_SETTINGS = {
'GCM_API_KEY': 'xxxxx',
'APNS_CERTIFICATE': 'xxxxx.pem',
'USER_MODEL': User, # i want to change the default from auth_user to my_app User
}
但它在这一行引发了一个错误:
from my_app.models import User
错误是:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
如何在 setting.py 中加载 my_app 模型?