Open warvariuc opened 9 years ago
+1
+1
+1
+1
The same issue in Django is solved thanks to a Pylint plugin.
Indeed, in an ideal world, you'd rather make the checker more clever than adapt the software to the checker's shortcomings.
If it is too much work, it might not be worth the pain, though.
Hopefully, we only need the equivalent of a small subpart of the Django checker. From a quick glance, it looks like this file addresses those issues.
+1
@lafrech
Indeed, in an ideal world, you'd rather make the checker more clever than adapt the software to the checker's shortcomings.
I don't thing adapting a checker to a particular project is also a clever idea. For example autocompletion in PyCharm also fails in this case.
pylint is still failing on .objects call - any workaround?
same here
Any update on this issue? It has been almost a year ...
I added "Python for VSCode" add-on and the problem is resolved in my case.
@javsal I added the same extension but it still throws that same error :/
@javsal I installed "Python for VSCode" add-on and still have the error
Class 'somemodel' has no 'objects' member (no-member)
it's some workaround ?
Same issue using "Python for VSCode".
pip install pylint-django
And add to VSC config:
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
it will solve the question, but it let my pylint all failure. whats happening and how to fix it?
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
Makes my pylint not working too @ghost, did you managed to make it work?
I was using pylint_django but when I tried to upgrade, it stopped working with mongoengine so I wrote this: https://github.com/jucacrispim/pylint-mongoengine
@JMGama Me too, are you fix this ?
from django.shortcuts import render
from .models import Job
def home(request):
jobs = Job.objects
return render(request, 'jobs/home.html', {"jobs":jobs} )`
I am getting error
{
"resource": "/c:/Users/Akhil/Desktop/django_stuff/portfolio-project/jobs/views.py",
"owner": "python",
"code": "no-member",
"severity": 8,
"message": "Class 'Job' has no 'objects' member",
"source": "pylint",
"startLineNumber": 8,
"startColumn": 12,
"endLineNumber": 8,
"endColumn": 12
}
Class 'Job' has no 'objects' member
What should i do now ?
setp 1. pip install pylint-django
setp 2. open VSCode -> File -> Preferences -> Settings -> search 'python.linting.pylintArgs'
setp 3. Add this in json.
"python.linting.pylintArgs" :[
"--load-plugins=pylint_django"
]
Edit "C:\Users\anmar\AppData\Roaming\Code\User\settings.json" and add
python.linting.pylintArgs lines at the end as shown below:
{
"team.showWelcomeMessage": false,
"python.dataScience.sendSelectionToInteractiveWindow": true,
"git.enableSmartCommit": true,
"powershell.codeFormatting.useCorrectCasing": true,
"files.autoSave": "onWindowChange",
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
"--errors-only"
],
}
Edit "C:\Users\anmar\AppData\Roaming\Code\User\settings.json" and add python.linting.pylintArgs lines at the end as shown below: { "team.showWelcomeMessage": false, "python.dataScience.sendSelectionToInteractiveWindow": true, "git.enableSmartCommit": true, "powershell.codeFormatting.useCorrectCasing": true, "files.autoSave": "onWindowChange", "python.linting.pylintArgs": [ "--load-plugins=pylint_django", "--errors-only" ], }
Great, this worked for me
def post_list(request): posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') return render(request, 'blog/post_list.html', {'posts': posts })
I had an issue where Post wouldn't let me use "objects" as it wasn't a member of the "Post" import, the setting this person posted helped me a lot, thanks!
if we do this only `"python.linting.pylintArgs": [ "--load-plugins=pylint_django"
],`
it gives other errors but this does magic
"python.linting.pylintArgs": [ "--load-plugins=pylint_django", "--errors-only" ],
thanks for help
I fixed this issue by:
First, install python package pylint-django
pip install pylint-django
then open the project folder .vscode/settings.json and add:
{
...
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
...
}
then the message was gone.
def home(request):
jobs = Job.objects
return render(request, 'jobs/home.html', {"jobs":jobs} )`
I got the same error when implementing Model.get_FOO_display() - Django; in vscode .
from django.db import models
class Plan(models.Model):
PLAN_CHOICES = [
('T', 'Talk More'),
('S', 'STANDARD),
]
name = models.CharField(
choices=PLAN_CHOICES,
default='S',
max_length=255,
)
def __str__(self):
return self.get_name_display()
return self.get_name_display()
Instance of 'Plan' has no 'get_name_display' memberpylint(no-member)
join @david-daming and @ajaysbugatti Thanks!!!
I did the: "python.linting.pylintArgs": [ "--load-plugins=pylint_django" ], and "python.linting.pylintArgs": [ "--load-plugins=pylint_django", "--errors-only" ], and stop the problems messages, but also stop other error messages
use pylint --disable no-member to suppress no-member error messages.
For me it is working..
Similar need here: #2326
That's a really annoying issue. Why would one install pylint_django
even if they don't use Django at all?
use pylint --disable no-member to suppress no-member error messages.
For me it is working..
i followed this and it works but... i just don't know if this is right... doesn't this issue have a perfect solution?
PyLint is complaining:
This is because
objects
is assigned in the metaclassbase/metaclasses.py:345
:I think having it defined in the base document would have the effect but be more discoverable:
Similarly you could do
Also the per-class exceptions can have their names to include model name:
Thus Sentry having such an exceptions +
__repr__
would give hint what model the exception belongs to.