# Django custom user shows as AbstractBaseUser rather AbstractUser

**URL:** <https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358>\
**Category:** Getting Started\
**Created:** [April 11, 2025, 12:17pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358 "2025-04-11T12:17:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nizumzen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nizumzen/32/16119_2.png) [@Nizumzen](https://forum.djangoproject.com/u/Nizumzen)\
**Post date:** [April 11, 2025, 12:17pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/1 "2025-04-11T12:17:10Z")

</div>

I’m not sure about how to go about debugging this. I’ll try and explain as well as I can but if you need additional information then please let me know.

I have a custom user model like so:

```
class CustomUser(AbstractUser):
    email = models.EmailField(unique=True, blank=False, null=False)
    email_verified = models.BooleanField(default=False)
    email_verify_code = models.UUIDField(editable=False, null=True, blank=True)
    email_verify_code_expired = models.DateTimeField(null=True, blank=True)

```

and in my custom login view I have this:

```
username = form.cleaned_data.get('username')
password = form.cleaned_data.get('password')
user = authenticate(self.request, username=username, password=password)

```

when I try and do:

```
user.email_verified

```

it says that the email\_verified field does not exist.

I noticed that PyCharm reports the user model as being an AbstractBaseUser but I have no idea why.

Can someone point me in the right direction please?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2025, 12:24pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/2 "2025-04-11T12:24:47Z")

</div>

> [@Nizumzen](#):
>
> when I try and do:
> 
> ```auto
> user.email_verified
> 
> ```
> 
> it says that the email\_verified field does not exist.

Please provide the full context where you’re trying to use this - what file / function / module?

> [@Nizumzen](#):
>
> I noticed that PyCharm reports the user model as being an AbstractBaseUser but I have no idea why.

`AbstractUser` is a descendant class of `AbstractBaseUser`.

---

<div class="post-metadata">

**Author:** ![Nizumzen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nizumzen/32/16119_2.png) [@Nizumzen](https://forum.djangoproject.com/u/Nizumzen)\
**Post date:** [April 11, 2025, 12:28pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/3 "2025-04-11T12:28:42Z")

</div>

Here is my login view:

```
class CustomLoginView(FormView):
    template_name = 'registration/login.html'
    form_class = AuthenticationForm
    success_url = reverse_lazy('user:account') # Redirect to the account page after login

def form_valid(self, form):
    username = form.cleaned_data.get('username')
    password = form.cleaned_data.get('password')
    user = authenticate(self.request, username=username, password=password)
    if user is not None:
        if user.email_verified is False:
            return render(self.request, 'registration/login.html', {
                'form': form,
                'error': 'Email not verified. Please check your email for verification link.'
            })
        else:
            login(self.request, user)
            return redirect(self.get_success_url())
    else:
        return self.form_invalid(form)

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2025, 12:38pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/4 "2025-04-11T12:38:47Z")

</div>

What is your `AuthenticationForm`?

---

<div class="post-metadata">

**Author:** ![Nizumzen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nizumzen/32/16119_2.png) [@Nizumzen](https://forum.djangoproject.com/u/Nizumzen)\
**Post date:** [April 11, 2025, 12:45pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/5 "2025-04-11T12:45:24Z")

</div>

Just the default one:

```
django.contrib.auth.forms.AuthenticationForm

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2025, 12:58pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/6 "2025-04-11T12:58:56Z")

</div>

Did you set the `AUTH_USER_MODEL` setting in your `settings.py`?

---

<div class="post-metadata">

**Author:** ![Nizumzen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nizumzen/32/16119_2.png) [@Nizumzen](https://forum.djangoproject.com/u/Nizumzen)\
**Post date:** [April 11, 2025, 4:02pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/7 "2025-04-11T16:02:45Z")

</div>

Yes I did. I just double checked.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2025, 4:06pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/8 "2025-04-11T16:06:51Z")

</div>

Side note: I hope your posting of the `CustomLoginView` is _not_ exactly as it exists in your source file - your `form_valid` method is not indented within your `CustomLoginView` class.

Please post your complete settings.py file.

---

<div class="post-metadata">

**Author:** ![Nizumzen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nizumzen/32/16119_2.png) [@Nizumzen](https://forum.djangoproject.com/u/Nizumzen)\
**Post date:** [April 11, 2025, 5:28pm UTC](https://forum.djangoproject.com/t/django-custom-user-shows-as-abstractbaseuser-rather-abstractuser/40358/9 "2025-04-11T17:28:23Z")

</div>

Hi, thank you so much for your help. I rejigged things so now I call the verification code from a login signal and that sorted the problem out.

Also yeah the indentation things was my bad when pasting the code here.
