# I do not use the username field of the auth\_user.

**URL:** <https://forum.djangoproject.com/t/i-do-not-use-the-username-field-of-the-auth-user/17943>\
**Category:** Getting Started\
**Created:** [January 1, 2023, 9:48pm UTC](https://forum.djangoproject.com/t/i-do-not-use-the-username-field-of-the-auth-user/17943 "2023-01-01T21:48:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [January 1, 2023, 9:48pm UTC](https://forum.djangoproject.com/t/i-do-not-use-the-username-field-of-the-auth-user/17943/1 "2023-01-01T21:48:17Z")

</div>

Hello everyone. In my application the login is done by email and not by a username. Is it advisable to create a custom model of the User model or is it possible to just copy the email field to the username?

Because currently the username field is empty and I get the following console output:

```
 django.db.utils.IntegrityError: UNIQUE constraint failed: auth_user.username

```

Which I understand that I get it because when the first user registers, the username field is left blank.

**Is it advisable to copy what goes in the email field in the username field?**

---

<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:** [January 1, 2023, 11:21pm UTC](https://forum.djangoproject.com/t/i-do-not-use-the-username-field-of-the-auth-user/17943/2 "2023-01-01T23:21:45Z")

</div>

> [@julianov](#):
>
> Is it advisable to copy what goes in the email field in the username field?

Sure - that’s one way to do it.

There’s no “right” or “wrong” here - it’s an architectural decision that should be made in the context of the overall requirements for the system.

---

<div class="post-metadata">

**Author:** ![leandrodesouzadev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/leandrodesouzadev/32/8981_2.png) [@leandrodesouzadev](https://forum.djangoproject.com/u/leandrodesouzadev)\
**Post date:** [January 2, 2023, 11:10am UTC](https://forum.djangoproject.com/t/i-do-not-use-the-username-field-of-the-auth-user/17943/3 "2023-01-02T11:10:30Z")

</div>

If you’re not willing to use the `username` field, you can remove it.

```python
from django.contrib.auth.models import AbstractBaseUser
from django.contrib.auth.models import PermissionsMixin

class YourUserModel(PermissionsMixin, AbstractBaseUser):
  username = None
  # Your other fields

```

---

<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:** [January 2, 2023, 12:44pm UTC](https://forum.djangoproject.com/t/i-do-not-use-the-username-field-of-the-auth-user/17943/4 "2023-01-02T12:44:47Z")

</div>

That is another way to do it, but then he’s no longer using the standard default User model.
