Doing the following in models.py from a Django Project:
from django.contrib.auth.models import User
from django.db import models
class Pizza(models.Model):
"""A pizza that our clients can order."""
name = models.CharField(max_length=250)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
"""Return a string representation of the model."""
return str(self.name)
I got the following pylint error:
User model imported from django.contrib.auth.models Pylint(E5142:imported-auth-user)
Why is Pylint rising this error? Despite the fact that everything seems to be configured right. Virtual env, python interpreter, pylint-django...
Thanks in advance...
I fixed it doing the following:
from django.contrib.auth import models as auth_models
from django.db import models
class Pizza(models.Model):
"""A pizza that our clients can order."""
name = models.CharField(max_length=250)
owner = models.ForeignKey(auth_models.User, on_delete=models.CASCADE)
def __str__(self):
"""Return a string representation of the model."""
return str(self.name)
Importing django.contrib.auth.models
in the same way as Django does with its db models.