Django: Class has no 'objects' member
It's just a pylint error nothing to worry.
class has no 'objects' member
Try with this
Use pylint --generated-members=objects
Install Django pylint:
pip install pylint-django
ctrl+shift+p > Preferences: Configure Language Specific Settings > Python
The settings.json available for python language should look like the below:
{
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
"[python]": {
}
}
Class has no 'objects' member in django
You have two different issues, and not just one as you say:
E1101:Class 'Destination' has no 'objects' member
: Is a warning
that occurs because pylint
doesn't know about our special Django variables. A pylint plugin like pylint-django
might do the trick.
E0601:Using variable 'Destination' before assignment
: In the for loop in your code you defined a variable called Destination
. This is not only bad practice because python variables need to be in lowercase_underscore
but it overrides the Destination
class, and that's what is causing this error. You probably wanted to do something like this:
for d in boards:
# Or:
for destination in boards:
Pylint and classes that share the same name showing no member error
I managed to get it working by using relative import,
so instead of
from config import Config
do
from .config import Config
I also need to add an empty __init__.py
file:
Lambda1 (folder)
|_ __init__.py
|_ config.py
|_ lambda_function.py
Lambda2 (folder)
|_ __init__.py
|_ config.py
|_ lambda_function.py
This would get Pylint to detect the correct class.
The next issue was that these changes would cause the lambda to no longer work.
To get the lambda working again I added a folder within each lambda folder like this:
Lambda1 (folder)
|_ app (folder)
|_ __init__.py
|_ config.py
|_ lambda_function.py
Lambda2 (folder)
|_ app (folder)
|_ __init__.py
|_ config.py
|_ lambda_function.py
And updated the lambda handler from this:
Handler: lambda_function.lambda_handler
to this:
Handler: app.lambda_function.lambda_handler
I'm not too happy that I need to restructure the files and update the lambda handler, so will continue looking at alternative solutions to avoid this.
class 'product' has no 'objects' member
These issues are just warnings from your Linter that is not following Django internal behavior (objects
is a method that is coming from the Django class your product
class is inheriting from). Install Pylint django
Related Topics
Split a List into Nested Lists on a Value
Python's in (_Contains_) Operator Returns a Bool Whose Value Is Neither True Nor False
How to Get All Combinations of Length N in Python
Running a Tkinter Form in a Separate Thread
What Is Sys.Maxint in Python 3
Numpy: Fix Array with Rows of Different Lengths by Filling the Empty Elements with Zeros
Duplicate Items in Legend in Matplotlib
Export a Pandas Dataframe as a Table Image
Same Output in Different Workers in Multiprocessing
Screenshot of Inactive Window Printwindow + Win32Gui
Matplotlib Connect Scatterplot Points with Line - Python
How to Open Multiple Webpages in Separate Tabs Within a Browser Using Selenium-Webdriver and Python
How to Open a File Through Python
Django Model Field Default Based Off Another Field in Same Model
Pyspark: Explode JSON in Column to Multiple Columns
Python Selenium: Wait Until Element Is Clickable - Not Working