Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importing User from django auth models #278

Closed
eronmedeiros opened this issue Aug 2, 2020 · 6 comments
Closed

Error importing User from django auth models #278

eronmedeiros opened this issue Aug 2, 2020 · 6 comments

Comments

@eronmedeiros
Copy link

eronmedeiros commented Aug 2, 2020

Hey there,
I'm getting an error and I don't know why it is showing up.
It is a new django project. I'm running everything normally.

Except, on every code that imports:
from django.contrib.auth.models import User

It says:
User model imported from django.contrib.auth.models pylint(imported-auth-user)

It shows no error code, so I can't even remove it like I did with function doc string errors, in the .pylintrc file.

carlio added a commit that referenced this issue Aug 2, 2020
@carlio
Copy link
Member

carlio commented Aug 2, 2020

@eronmedeiros I think that's because that error message was missing the decorator. Can you try installing pylint-django from this branch and see if it fixes things? https://github.com/PyCQA/pylint-django/tree/bugfix/278-add-auth-user-error-code

@atodorov I think my branch here will fix things: https://github.com/PyCQA/pylint-django/tree/bugfix/278-add-auth-user-error-code

atodorov pushed a commit that referenced this issue Aug 4, 2020
@atodorov
Copy link
Contributor

atodorov commented Aug 4, 2020

@atodorov I think my branch here will fix things: https://github.com/PyCQA/pylint-django/tree/bugfix/278-add-auth-user-error-code

@carlio I've merged this into master. Closing this issue.

@atodorov atodorov closed this as completed Aug 4, 2020
@gdowdy3
Copy link

gdowdy3 commented Aug 14, 2020

Hey guys, I encountered the same error and disabled it using the error number provided by the bug fix described above. So thanks for providing that error number. 👍

I'm wondering, though: why is that error message appearing in the first place? The line of code

from django.contrib.auth.models import User

comes straight from the Django documentation: https://docs.djangoproject.com/en/3.1/topics/auth/default/

Why should it give an error?

@atodorov
Copy link
Contributor

comes straight from the Django documentation: https://docs.djangoproject.com/en/3.1/topics/auth/default/

Why should it give an error?

#244

FTR Django doesn't always document or even follow its practices.

@IRezig
Copy link

IRezig commented Sep 7, 2020

Hello guys,
I had this issue too and I fixed it by

  1. Installing Pylint
    pip install pylint-django

  2. create .pylintrc file (in racin of your project) and add:
    --load-plugins pylint_django
    Hope that help you

Bonne journée

@cyclops26
Copy link

Hey guys, I encountered the same error and disabled it using the error number provided by the bug fix described above. So thanks for providing that error number. 👍

I'm wondering, though: why is that error message appearing in the first place? The line of code

from django.contrib.auth.models import User

comes straight from the Django documentation: https://docs.djangoproject.com/en/3.1/topics/auth/default/

Why should it give an error?

@gdowdy3 I believe it might be because they recognize that people may replace the User model with their own custom model.

Tucked away in the docs is this https://docs.djangoproject.com/en/3.1/topics/auth/customizing/#referencing-the-user-model

Not saying that the other documentation doesn't need updating, but this would be my suspicion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants