ImportError: cannot import name 'Users' from partially initialized module 'users.models
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=["[email protected]", ],
fail_silently=False,
)
print('Email sent successfully')
return f'Email sent successfully'
checking installing celery
CodePudding user response:
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
CodePudding user response:
I import my model in this way:
model = apps.get_model(app_label='users', model_name='users')
when the users is name the folder