[英]ImportError: cannot import name 'Users' from partially initialized module tasks file
ImportError: cannot import name 'Users' from partially initialized module 'users.models ImportError:无法从部分初始化的模块“users.models”中导入名称“Users”
from .models import Users
from celery import shared_task
from django.core.mail import send_mail
from server import settings
@shared_task()
def send_mail_task(user_id):
user = Users.objects.get(id=user_id)
send_mail(
subject='Congratulations!',
message=f'Congratulations {user.username}',
from_email=settings.EMAIL_HOST_USER,
recipient_list=["waelelsafty07@gmail.com", ],
fail_silently=False,
)
print('Email sent successfully')
return f'Email sent successfully'
checking installing celery检查安装芹菜
could you post your working directory so i can see where is the files are if you didnt customize the user model then use你能发布你的工作目录吗,这样我就可以看到文件在哪里,如果你没有自定义用户模型然后使用
from django.contrib.auth.models import User
I import my model in this way:我以这种方式导入我的模型:
model = apps.get_model(app_label='users', model_name='users')
when the users is name the folder当用户命名文件夹时
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.