Member-only story

Django Developer Should Know(Part-1)

Rajan Sahu
3 min readApr 8, 2023

--

My article is for everyone! Non-members can click on this link and jump straight into the full text!!

This article is mainly for Django insiders where we will see some essential concepts, changing the default behavior of the Django app.

1. Let's start with understanding a statement

  • Django application we always heard the statement “No activity of the database occurs until we evaluate it”.
  • Let’s create a model and try to understand this statement.
class Items(models.Model):
name = models.CharField(max_length=20)
price = models.IntegerField()

As you can see the below records we have inserted into the Items model

Take a look at the following example to understand laziness :

>> items = Items.objects.filter(id__lte=3)
>> item_mango = items.filter(name = "Mango")
>> mango_list= list(item_mango)

From the above query, It looks like we are hitting the database twice, but in fact, it hits the…

--

--

Rajan Sahu
Rajan Sahu

Written by Rajan Sahu

Backend and Data Engineer by Day; Teacher, Friend and Content-Writer by night.

No responses yet