Take a look at how your template is displaying. Your project page is showing the title, description, and technology! Now let’s use the for loop to display all of the projects. You’re going to add data through the Django shell. To start the Django shell, type the following:
$ python manage.py shell
You need to modify models.py. You’re going to have to import:
>>> from projects.models import Project
Now, you’re able to create another instance of Project:
Martin Breuss RP Team on Jan. 8, 2020
Yes, these are two different ways of doing the same thing, and the second one can be cleaner and more intuitive if you know the primary key of the object you want to access. Thanks for summing it up :)
Two Notes
Typo In Argument Passing: The first line of the second code block needs to read:
You’re passing the number
1as a keyword argument to theget()method. That’s most likely just a typo, but I wanted to make sure no one gets confused when trying to use your code :)Verifying Changes: Accessing the object (
p1) again after callingp1.save()doesn’t tell you anything about changes to the content of your database. You are again just checking up on thep1object you created and edited before.If you want to verify that the data changed in the database, you’ll need to make another call to the database before, like so: