importterror:无法从部分初始化的模块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'
检查安装芹菜
我是这样导入模型的:
model = apps.get_model(app_label='users', model_name='users')
当用户被命名文件夹
你可以张贴你的工作目录,这样我就可以看到文件在哪里如果您没有自定义用户模型,则使用
from django.contrib.auth.models import User