I\'m using a custom user model, extended with AbstractUser. Here\'s my models.py:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from d
To better understand the issue, I'll illustrate how I solved this problem. For me moving one of the import statement (which internally used the User model) from the top of the file and placing it after the User model is defined fixed the issue
from django.contrib.auth.models import AbstractUser, BaseUserManager
from django.db import models
from django.db.models.signals import post_save
from rest_framework.authtoken.models import Token
from .utils import generate_token, send_email, generate_id
class User(AbstractUser):
"""User model."""
username = None
email = models.EmailField(_('email address'), unique=True)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
objects = UserManager()
#### Moved the import statement here so that the issue is solved.
#### This function internally used User model which is only defined right above this.
from meter.tasks import apigeePipeline
def post_save_user_receiver(sender, instance, created, *args, **kwargs):
if created:
print("***********USer created**********")
token = Token.objects.create(user=instance)
send_email(instance.email, token.key)
apigeePipeline(instance)
post_save.connect(post_save_user_receiver, sender=User)