0

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

2 Answers 2

1

I import my model in this way:

model = apps.get_model(app_label='users', model_name='users')

when the users is name the folder

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

I created app users inheritance from an abstractuser class ``` users/ models.py tasks.py ```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.