In lesson 41 Mosh called the objects attribute from the Product class, but in my case no such attribute exists (as shown in the picture above).
Could anyone help me?
Thanks in advance,
Jonas
In lesson 41 Mosh called the objects attribute from the Product class, but in my case no such attribute exists (as shown in the picture above).
Could anyone help me?
Thanks in advance,
Jonas
Hi, on the top try:
“from store.models import Product” not what you have there of “from storefront.store.models import Product”
Will it work?
You have djangoproject as your root folder not storefront. You will see on 5 - Creating your first django project Mosh delete’s root folder
Its still the same, the path to your project is PycharmProjects\djangoproject see at the top
I don’t see any underlined errors there, whats the error message or code you are getting?
from django.shortcuts import render
from django.http import HttpResponse
from store.models import Product
def say_hello(request):
Product.objects **# <---- error ( it dosen´t find the objects attribute of any model i made)**
return render(request, 'hello.html', {'name': 'Jonas'})
my file tree now:
If the issue relates to intellisense or code suggestions, I think it may be an issue with your IDE as opposed to the actual source code. Try the steps below one by one to see if it solves your issue:
Check if the project interpreter is set correctly: Go to “Settings” or “Preferences” in PyCharm (depending on your operating system) and navigate to “Project: [Your Project Name]” > “Python Interpreter.” Make sure that the correct interpreter is selected for your project.
Invalidate caches and restart: Go to “File” > “Invalidate Caches / Restart” and choose “Invalidate and Restart.” This action will clear the caches and restart PyCharm.
Ensure that the necessary packages are installed: Make sure that you have installed all the required packages for your project. You can use the package manager or a virtual environment to manage your packages. Check if the necessary packages are installed and accessible by PyCharm.
Confirm that the file is in a recognized source root: Ensure that the file you are working on is located within a recognized source root of your PyCharm project. PyCharm may not provide IntelliSense for files outside of the recognized source roots.
Enable the “Autocomplete” feature: Check if the “Autocomplete” feature is enabled in your PyCharm settings. Go to “Settings” or “Preferences” > “Editor” > “General” > “Code Completion” and make sure that “Autocomplete” is selected.
Wait for indexing to complete: PyCharm performs indexing in the background to build its code analysis database. If you have recently opened a large project or made significant changes, give PyCharm some time to finish indexing. You can see the indexing progress in the bottom-right corner of the PyCharm window.
Restart PyCharm: If none of the above steps work, try restarting PyCharm to see if it resolves the issue.