I upload my Django web app to Heroku successfully and login page appears as well as expected but when I try login I getting this error:
relation "accounts_user" does not exist
LINE 1: ...ser"."is_active", "accounts_user"."is_staff" FROM "accounts_...
Also I am getting this error when I try to acces ulrs
by typing
cursor "_django_curs_140062995079296_sync_1" does not exist
I don't know where this error Is generating from. But I am using custom user models that I seems the error to be there
here is the custom user model I used
class UserManager(BaseUserManager):
use_in_migrations = True
def _create_user(self, email, password, **extra_fields):
"""
Creates and saves a User with the given email and password.
"""
if not email:
raise ValueError('The given email must be set')
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
def create_user(self, email, password=None, **extra_fields):
extra_fields.setdefault('is_superuser', False)
return self._create_user(email, password, **extra_fields)
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_superuser', True)
if extra_fields.get('is_superuser') is not True:
raise ValueError('Superuser must have is_superuser=True.')
return self._create_user(email, password, **extra_fields)
class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField( unique=True)
name = models.CharField(max_length=200, null=True)
staffType = models.ForeignKey(staffType, null=True, on_delete= models.SET_NULL)
date_joined = models.DateTimeField( auto_now_add=True)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField( default=True)
objects = UserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
class Meta:
verbose_name = 'user'
verbose_name_plural = 'users'
def email_user(self, subject, message, from_email=None, **kwargs):
'''
Sends an email to this User.
'''
send_mail(subject, message, from_email, [self.email], **kwargs)