pylint E5142 (imported-auth-user)

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

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.

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

1 Like