1

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)



  • 1
    Did you run `python manage.py migrate` on server? – iliya May 10 '20 at 17:53
  • @iliya how I can run – Badri Abdilaah May 10 '20 at 18:04
  • with command like this `heroku run python manage.py migrate` or you can login in to your project (`heroku login`) then running this `heroku run bash -a your-project-name` and then run the command above. – iliya May 10 '20 at 18:11
  • @iliya thanks men you saved me. but I have other problem when I try to access web from other devices it redirects to Heroku page with ` **There's nothing here,ye** – Badri Abdilaah May 11 '20 at 11:21
  • wll done. For the second problem I suggest search a little since the problem has many reasons, I searched and found two or three at least. Take a look at this [https://stackoverflow.com/questions/53026340/herokudns-with-custom-domain-no-such-app/53093756#53093756 ] . Also appreciate vote up right answers. – iliya May 11 '20 at 16:33

0 Answers0