[Answer]-Why can´t I save an object when I am using AUTH_USER_MODEL parameter?

1👍

@Catherine and @Sid were correctly! Thanks Guys!

In my save method I forget to indent super().

It was:

def save(self, *args, **kwargs):

    if not self.hash:
        now = time.localtime(time.time())
        time_formatted=time.strftime("%Y-%m-%d %H:%M:%S", now)
        hash="%s%s" % (time_formatted, self.email)
        self.hash=hashlib.sha1(hash).hexdigest()
        super(MyUser, self).save(*args, **kwargs)

when the correct is:

def save(self, *args, **kwargs):
    if not self.hash:
        now = time.localtime(time.time())
        time_formatted=time.strftime("%Y-%m-%d %H:%M:%S", now)
        hash="%s%s" % (time_formatted, self.email)
        self.hash=hashlib.sha1(hash).hexdigest()
    super(MyUser, self).save(*args, **kwargs)
👤Thomas

Leave a comment