# ValueError with custom user

**URL:** <https://forum.djangoproject.com/t/valueerror-with-custom-user/31992>\
**Category:** Using the ORM\
**Created:** [June 12, 2024, 2:12am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992 "2024-06-12T02:12:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lisa928](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lisa928/32/21912_2.png) [@lisa928](https://forum.djangoproject.com/u/lisa928)\
**Post date:** [June 12, 2024, 2:12am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/1 "2024-06-12T02:12:46Z")

</div>

ValueError: The field admin.LogEntry.user was declared with a lazy reference to ‘authentication.customuser’, but app ‘authentication’ doesn’t provide model ‘customuser’. The field authentication.UserProfile.user was declared with a lazy reference to ‘auth’

```auto
PS C:\Users\Hp\Desktop\my final year project\django_project\init_auth_django-master> python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, authentication, contenttypes, sessions
Traceback (most recent call last):
  File "C:\Users\Hp\Desktop\my final year project\django_project\init_auth_django-master\manage.py", line 22, in <module>
    main()
  File "C:\Users\Hp\Desktop\my final year project\django_project\init_auth_django-master\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\core\management\ __init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\core\management\ __init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\core\management\base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\core\management\base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\core\management\commands\migrate.py", line 302, in handle
    pre_migrate_apps = pre_migrate_state.apps
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\utils\functional.py", line 47, in __get__
    res = instance. __dict__ [self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\db\migrations\state.py", line 566, in apps
    return StateApps(self.real_apps, self.models)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hp\Desktop\my final year project\venv\Lib\site-packages\django\db\migrations\state.py", line 637, in __init__
    raise ValueError("\n".join(error.msg for error in errors))
ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'authentication.customuser', but app 'authentication' doesn't provide model 'customuser'.
The field authentication.UserProfile.user was declared with a lazy reference to 'authentication.customuser', but app 'authentication' doesn't provide model 'customuser'.
PS C:\Users\Hp\Desktop\my final year project\django_project\init_auth_django-master>

```

---

<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:** [June 12, 2024, 2:15am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/2 "2024-06-12T02:15:15Z")

</div>

Welcome @lisa928 !

Just a couple things to point out here.

- Please don’t try to describe the complete issue in the title. The title should be a brief statement of the issue. The full description should be in the body of your post.

- When posting code (or templates, error messages, tracebacks, etc), enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of editing your original post. Please remember to do this in the future.)

---

<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:** [June 12, 2024, 2:20am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/3 "2024-06-12T02:20:27Z")

</div>

Please provide more details about your project. Describe what sort of user and profile models you’re using, and what you have done with this project so far. (i.e., is this an existing project you are enhancing? Or is this a new project where you’re just getting started?)

---

<div class="post-metadata">

**Author:** ![lisa928](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lisa928/32/21912_2.png) [@lisa928](https://forum.djangoproject.com/u/lisa928)\
**Post date:** [June 12, 2024, 2:29am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/4 "2024-06-12T02:29:02Z")

</div>

I’m building on existing project

---

<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:** [June 12, 2024, 2:33am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/5 "2024-06-12T02:33:05Z")

</div>

What changes have you made to the project since the last working version?

---

<div class="post-metadata">

**Author:** ![lisa928](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lisa928/32/21912_2.png) [@lisa928](https://forum.djangoproject.com/u/lisa928)\
**Post date:** [June 12, 2024, 2:46am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/6 "2024-06-12T02:46:45Z")

</div>

I added RSA and AES cryptography functionalities and I wanted to add two factor authentication using Twilio sms during login.

---

<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:** [June 12, 2024, 2:50am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/7 "2024-06-12T02:50:48Z")

</div>

You’re going to need to provide all the details about these changes.

Also, did you start your project with a custom user model, or are you adding this as part of these updates?

---

<div class="post-metadata">

**Author:** ![lisa928](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lisa928/32/21912_2.png) [@lisa928](https://forum.djangoproject.com/u/lisa928)\
**Post date:** [June 12, 2024, 10:40am UTC](https://forum.djangoproject.com/t/valueerror-with-custom-user/31992/8 "2024-06-12T10:40:50Z")

</div>

I created the **CustomUser** function inside authentication model
