Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialnassar hayat
14,509 PointsSuperuser isn't marked as being staff
"Superuser isn't marked as being staff". This answer looks correct to me, but keep getting error with superuser isn't marked as being staff.
from django.contrib.auth.models import BaseUserManager
class UserManager(BaseUserManager):
def create_user(self, email=None, dob=None, accepted_tos=None, password=None):
if accepted_tos != True:
raise ValueError("Error")
user = self.model(
email=self.normalize_email(email),
dob=dob,
accepted_tos=accepted_tos
)
user.set_password(password)
user.save()
return user
def create_superuser(self, email, password, dob, accepted_tos=None):
user = self.create_user(
email,
dob,
accepted_tos,
)
user.is_superuser = True
user.is_staff = True
user.accepted_tos = True
user.save()
return user
4 Answers
Alx Ki
Python Web Development Techdegree Graduate 14,822 PointsHi, nassar hayat !
Your create_superuser should be corrected:
- accepted_tos should not be in arguments of create_superuser().
- accepted_tos=True must be set in self.create_user()
best, alexey
Asma Al-Marrikhi
45,525 Pointsyou should :
- remove accepted_tos from method arguments.
- in user model:
- accepted_tos=True
- add password = password
def create_superuser(self, email, dob, password):
user = self.create_user(
email,
dob,
accepted_tos=True,
password=password
)
user.is_staff = True
user.is_superuser = True
user.save()
return user
nassar hayat
14,509 Pointsthanks
HUB Customer Central
20,702 PointsI'm getting the same error as well. :( My code is the same as this.
Asma Al-Marrikhi
45,525 Pointslook at the next challenge, the correct code there .. :)
nassar hayat
14,509 PointsThanks everyone for answering. I gave up on this a while back and have now moved my focus to using flask. Much appreciated nonetheless.
Asma Al-Marrikhi
45,525 Pointslook at the next challenge, the correct code there .. :)
nassar hayat
14,509 Pointsnassar hayat
14,509 Pointsthanks