Python Django Authentication Users and Authorization Custom User Model

HUB Customer Central
HUB Customer Central
20,698 Points

Custom User Model: Bummer! Try again!

I'm not sure why this code is not passing. The only feedback I am getting is "Bummer! Try again!" which isn't helpful at all. Any ideas?

The question is as follows:

Create a new class named User that extends AbstractBaseUser and PermissionsMixin.

Give it three fields: email, dob, and accepted_tos.

  • email should be an EmailField and should be unique
  • dob should be a DateField
  • accepted_tos should be a BooleanField.
  • All three fields should be required.
from django.contrib.auth.models import (
from django.db import models
from django.utils import timezone

class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True, required=True)
    dob = models.DateField(required=True)
    accepted_tos = models.BooleanField(default=False, required=True)

2 Answers

Chris Freeman
Chris Freeman
Treehouse Moderator 65,181 Points

While the challenge text says "All three fields should be required", according the Field.required docs: "By default, each Field class assumes the value is required...." So, adding required=True should be a non-issue. However, the checker doesn't want the required parameter explicitly set. Also, the challenge checker wants a default value for the DateField.

:point_right: remove required from field arguments

:point_right: add default to DateField. works.

Chris Freeman
Chris Freeman
Treehouse Moderator 65,181 Points

Tagging @Kenneth Love: Is it possible for the checker to accept required=True in the challenge solution?

Chris Howell
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,608 Points

Hey Brandon Wells

Make sure you are not adding extra attributes it hasn't explicitly asked for, such as required inside each of your fields. Because the tests are looking for specific things, sometimes adding your own extras can make them fail.

HUB Customer Central
HUB Customer Central
20,698 Points

The question states that all three fields should be required though.