fcm_django.fcmdevice.user:(fields.e301)字段定义了与模型'auth.user'
在此项目中,我使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 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'