fcm_django.fcmdevice.user:(fields.e301)字段定义了与模型'auth.user'

发布于 2025-01-19 16:28:50 字数 1300 浏览 2 评论 0原文

在此项目中,我使用FCM-DJANGO软件包在Flutter应用程序中进行推送通知。尽管我已经适当地设置了以下错误。请帮助我我写的错误!

fcm_django.FCMDevice.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
    HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.

这是我的FCM插条:

# FIREBASE_APP = firebase_admin.initialize_app()

FCM_DJANGO_SETTINGS = {
    # default: _('FCM Django')
    "APP_VERBOSE_NAME": "django_fcm",
    # Your firebase API KEY
    "FCM_SERVER_KEY": "AAAAGhkzsi8:APA91bGCGga9FZnwASRy8NtLpp7jpINJcWbUiz9EHOFIxJjla8yVlpGtdqL7QB5rII0vKKExkpUw9PuRHt6khrpgcqDxcbzQvCWzgsBmT4SRRfoCirpGFXETIdIetgxBvktKJYSdjf_O",
    # true if you want to have only one active device per registered user at a time
    # default: False
    "ONE_DEVICE_PER_USER": False,
    # devices to which notifications cannot be sent,
    # are deleted upon receiving error response from FCM
    # default: False
    "DELETE_INACTIVE_DEVICES": True,
}

DEFAULT_AUTO_FIELD = 'FcmDjangoConfig.default_auto_field'

,我还导入以下几行:

from fcm_django.apps import FcmDjangoConfig

firebase_admin.initialize_app()
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = './push_notification/serviceAccountKey.json'

In this project, I've used fcm-django package for push notifications in the flutter app. And I have got the following error though I've set up appropriately. Please help me what I wrote wrong!

fcm_django.FCMDevice.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
    HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.

Here is my fcm-settings:

# FIREBASE_APP = firebase_admin.initialize_app()

FCM_DJANGO_SETTINGS = {
    # default: _('FCM Django')
    "APP_VERBOSE_NAME": "django_fcm",
    # Your firebase API KEY
    "FCM_SERVER_KEY": "AAAAGhkzsi8:APA91bGCGga9FZnwASRy8NtLpp7jpINJcWbUiz9EHOFIxJjla8yVlpGtdqL7QB5rII0vKKExkpUw9PuRHt6khrpgcqDxcbzQvCWzgsBmT4SRRfoCirpGFXETIdIetgxBvktKJYSdjf_O",
    # true if you want to have only one active device per registered user at a time
    # default: False
    "ONE_DEVICE_PER_USER": False,
    # devices to which notifications cannot be sent,
    # are deleted upon receiving error response from FCM
    # default: False
    "DELETE_INACTIVE_DEVICES": True,
}

DEFAULT_AUTO_FIELD = 'FcmDjangoConfig.default_auto_field'

And, I also imported the following lines:

from fcm_django.apps import FcmDjangoConfig

firebase_admin.initialize_app()
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = './push_notification/serviceAccountKey.json'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你另情深 2025-01-26 16:28:50

由于 fcm_django_fcmdevice 模型有一个与经过身份验证的用户相关的 FK 字段用户。因此,如果您定义了自定义用户模型,只需将以下行添加到您的 settings.py 文件中
AUTH_USER_MODEL = 'your_App_name.CustomUserModelName'

As the fcm_django_fcmdevice model has a FK field user that is related to the authenticated user. So,if you have defined a custom user model just add the following line to your settings.py file
AUTH_USER_MODEL = 'your_App_name.CustomUserModelName'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文