アプリの models.py で、次のようなカスタム ユーザー モデルへの外部キーのデフォルト値を定義しようとしています。
owner = models.ForeignKey(settings.AUTH_USER_MODEL, null=False,
default=get_user_model().objects.get()[0].pk)
カスタム ユーザー モデルも同じ models.py で定義されています。
ただし、使用しようとすると、別のアプリ models.py で醜い循環インポートの問題が発生しますget_user_model()
。
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to
model 'myapp.MyCustomUserModel' that has not been installed
これを解決するにはどうすればよいですか?