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

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?

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.)

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