Reputation: 43
I'm setting up a custom user authentication, and when I try to create a superuser in powershell it gives me an error " [Previous line repeated 986 more times] RecursionError: maximum recursion depth exceeded" which is referring to my create_superuser()
def create_superuser(self, username, password=None):
user = self.create_superuser(
username,
password = password,
is_staff = True,
is_admin = True
)
user.save(using=self._db)
return user
Upvotes: 1
Views: 974
Reputation: 16
class UserProfileManager(BaseUserManager):
""" Manager para perfiles de usuario """
def create_user(self, username, password=None):
""" Crear Nuevo UserProfile """
if not username:
raise ValueError('username!!!')
#email= self.normalize_email(email)
user = self.model(username=uername)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, username, password):
user = self.create_user(username=username,
password = password,
is_staff=True,
is_admin = True)
user.save(using=self._db)
return user
Upvotes: 0
Reputation: 36008
It looks like you want to call an overloaded function.
In Python, there's no function overloading. Instead, a function can have a flexible signature (optional arguments, receiving any arguments via *args
and **kwargs
).
If you define two functions with the same name in the same scope, the one encountered later by the interpreter will simply replace the former.
So, you need to consolidate your two functions into one with a flexible signature. (Nothing prevents you from splitting off helper functions or anything under the hood, but they need to have different names).
Upvotes: 1