Django's ORM lets developers use Python classes and objects to interact with the database. This means you write Python code instead of SQL queries, making database work easier and less error-prone.
class Book(models.Model): title = models.CharField(max_length=100) book = Book(title='Learn Django') book.save()
Calling .save() on a Django model instance tells the ORM to write the data to the database. If the object is new, it inserts a new row; if it exists, it updates the row.
The correct way to query multiple objects matching a condition is using Book.objects.filter(). Other options are invalid methods or missing the manager.
The get() method expects exactly one matching record. If none exist, Django raises a DoesNotExist error.
The filter price__lt=2.00 selects products with price less than 2.00. Only 'Pen' has price 1.50, so the output is ['Pen'].
