# pylint E5142 (imported-auth-user)

**URL:** <https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748>\
**Category:** Forms & APIs\
**Created:** [October 12, 2020, 9:14am UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748 "2020-10-12T09:14:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleasi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mleasi/32/2179_2.png) [@mleasi](https://forum.djangoproject.com/u/mleasi)\
**Post date:** [October 12, 2020, 9:14am UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748/1 "2020-10-12T09:14:22Z")

</div>

Hi,

I’m newer to django and I would create good code using pylint

I can’t correct error:  
E5142: User model imported from django.contrib.auth.models (imported-auth-user)

with import line:  
from django.contrib.auth.models import User

Thank you  
Marco

---

<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:** [October 12, 2020, 1:41pm UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748/2 "2020-10-12T13:41:23Z")

</div>

Are you using some django-specific plugin for pylint? That doesn’t appear to be a standard pylint error code. (At least, I’m not finding it when I do pylint --list-msgs.)

It also doesn’t strike me as being an “Error” outside the context of a specific application, where the application has a pylint extension to catch this specific situation.

---

<div class="post-metadata">

**Author:** ![mleasi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mleasi/32/2179_2.png) [@mleasi](https://forum.djangoproject.com/u/mleasi)\
**Post date:** [October 12, 2020, 2:18pm UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748/3 "2020-10-12T14:18:30Z")

</div>

thank you very much for your interest, you have been very helpful

Yes, I’m using django plugin: pylint --load-plugins pylint\_django

but I did not know --list-msgs

So i tried and I discovered:  
:imported-auth-user (E5142): _User model imported from django.contrib.auth.models_  
Don’t import django.contrib.auth.models.User model. Use  
django.contrib.auth.get\_user\_model() instead!

Now i replaced:  
from django.contrib.auth.models import User  
(User, …  
with  
from django.db import models  
(settings.AUTH\_USER\_MODEL,

and the error message is resolved.

Thank you very much

---

<div class="post-metadata">

**Author:** ![elvissierra](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/elvissierra/32/10601_2.png) [@elvissierra](https://forum.djangoproject.com/u/elvissierra)\
**Post date:** [October 28, 2022, 5:26pm UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748/4 "2022-10-28T17:26:08Z")

</div>

Hello, im currently having this issue in my serializer.py file, im try to figure out this way but cannot format it. Where can i look at to alleviate this issue?

---

<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:** [October 28, 2022, 7:16pm UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748/5 "2022-10-28T19:16:49Z")

</div>

I don’t understand what you’re asking here. It might be helpful if you post the code you’re trying and the details of the errors you’re getting as a result of that.

(Note, when you post code here, enclose it between lines of three backtick - ` characters. This means you’ll have a line of ```, theny your code, then another line of ```. This will force the forum software to keep your code properly formatted.)

---

<div class="post-metadata">

**Author:** ![elvissierra](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/elvissierra/32/10601_2.png) [@elvissierra](https://forum.djangoproject.com/u/elvissierra)\
**Post date:** [October 31, 2022, 9:38pm UTC](https://forum.djangoproject.com/t/pylint-e5142-imported-auth-user/4748/6 "2022-10-31T21:38:45Z")

</div>

thank you for this, and i ended up figureing out the solution to my problem.
