What is the use of "user = self.model(useremail=BmUserManager.normalize_email(useremail))" ? is it used to create a new custom user?

django, django-views, python

Solution

The `model` attribute of a model manager is just a reference to the model class the manager has been created for. In this case it refers to whatever user model that will use this manager.

Problem

``` class BmUserManager(BaseUserManager): def create_user(self, useremail, display_name, password=None): if not useremail: raise ValueError('Users must have an email address') user = self.model(useremail=BmUserManager.normalize_email(useremail)) user.display_name = display_name user.email = useremail user.set_password(password) user.save(using=self._db) return user ``` what is the use of self.model(useremail=BmUserManager.normalize_email(useremail))?

Original source