django polls tutorial part 2

Link to polls app tutorial: Writing your first Django app, part 2 | Django documentation | Django

So accessing the API is being discussed in this part of the tutorial. And if I want to search for items in a database or search for primary keys in a model I can use the API to run primary key searches. Is that the main purpose of this API?

Or is it to create models?

Often times, like the error I am experiencing currently, I run into an error that says I need to supply a primary key or an object. Is this API method technquie shown in the tutorial a search method for that?

Assuming you’re referring to the paragraph: Playing with the API

The API referenced here is the database api.

The database API are the classes, functions, and methods that you use to access the database in Django.

The traditional method of accessing a relational database is through an API known as SQL. (Yes, relational databases do predate the use of SQL - originally SEQUEL. SEQUEL, later SQL, was designed as a “database access language”, so it is actually an API.)

Django adds an additional layer above that, giving an even easier interface for performing database operations like inserting, updating, searching, and deleting data.

It performs these operations on instances of models.

That API however is not intended to create Models. That’s the purpose of the makemigration and migrate commands.

Yes, those exercises in the tutorials do demonstrate how to use information in searches to find instances of models. Those are the patterns you need to be learing to be able to apply those principles in your own projects.

You may also want to read Making queries.