Problem with Retrieving objects in Django ORM

Hello, im working with Django tutorial from Mosh.
Yesterday i’ve replaced my original “storefront” project with the storefront downloaded from resource files from course files.
Now on “Retrieving objects” part in tutorial i have problem with my project site.
I’m working with PyCharm and postgreSQL (i’ve changed DB settings for postgres).
PROBLEM:

DoesNotExist at /playground/hello/

Product matching query does not exist.

Request Method: GET
Request URL: http://127.0.0.1:8000/playground/hello/
Django Version: 4.2.2
Exception Type: DoesNotExist
Exception Value: Product matching query does not exist.
Exception Location: C:\Users\wotpr\PycharmProjects\so it has begun\venv\Lib\site-packages\django\db\models\query.py, line 637, in get
Raised during: playground.views.say_hello
Python Executable: C:\Users\wotpr\PycharmProjects\so it has begun\venv\Scripts\python.exe
Python Version: 3.11.3
Python Path: [‘C:\Users\wotpr\PycharmProjects\so it has begun\storefront’, ‘C:\Users\wotpr\AppData\Local\Programs\Python\Python311\python311.zip’, ‘C:\Users\wotpr\AppData\Local\Programs\Python\Python311\DLLs’, ‘C:\Users\wotpr\AppData\Local\Programs\Python\Python311\Lib’, ‘C:\Users\wotpr\AppData\Local\Programs\Python\Python311’, ‘C:\Users\wotpr\PycharmProjects\so it has begun\venv’, ‘C:\Users\wotpr\PycharmProjects\so it has begun\venv\Lib\site-packages’]
Server time: Mon, 19 Jun 2023 14:04:29 +0000

Traceback Switch to copy-and-paste view

  • C:\Users\wotpr\PycharmProjects\so it has begun\venv\Lib\site-packages\django\core\handlers\exception.py, line 55, in inner

    1. response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^

Local vars

  • C:\Users\wotpr\PycharmProjects\so it has begun\venv\Lib\site-packages\django\core\handlers\base.py, line 197, in _get_response

    1. response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Local vars

  • C:\Users\wotpr\PycharmProjects\so it has begun\storefront\playground\views.py, line 6, in say_hello

    1. product = Product.objects.get(pk=1) ^^^^^^^^^^^^^^^^^^^^^^^^^

Local vars

  • C:\Users\wotpr\PycharmProjects\so it has begun\venv\Lib\site-packages\django\db\models\manager.py, line 87, in manager_method

    1. return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Local vars

  • C:\Users\wotpr\PycharmProjects\so it has begun\venv\Lib\site-packages\django\db\models\query.py, line 637, in get

    1. raise self.model.DoesNotExist( ^

Django is saying there is no product with id=1 (pk) found in the database.

Make sure you have run all your migrations and check your db settings are properly configured like db name, user password etc and server is running and all your models are properly defined.

Also check in pgadmin in the products table that there is a product with primary key 1 exists and you can connect and view that record in the table without errors