DevBridge

DevBridge Code is more than lines on a screen, it's the power to turn ideas into reality. Every bug you fix makes you stronger.

Every project you finish brings you closer to the life you dream of. Stay patient, stay curious, and never stop learning.

18/09/2026

Javascript exercise for beginners.

❌ Good to know for backend developers.✅✅If you are building an API and your serializer allows users to update their pass...
17/09/2026

❌ Good to know for backend developers.

✅✅If you are building an API and your serializer allows users to update their password, these passwords must be hashed with set_password() before they are saved.
In this situation, you will need to use the customer update() to help you with that.

1. Why do we need a custom update()?
Normally, DRF knows how to update an object:
serializer.save()

and internally it can do something similar to:
instance.username = validated_data["username"]
instance.email = validated_data["email"]
instance.save()

That's fine for ordinary fields.

But password is special.

You should never simply do:

user.password = "newpassword"
user.save()

because that would store the password incorrectly.

Instead, Django expects:
user.set_password("newpassword")
which hashes the password.

2. Why this line?
password = validated_data.pop("password", None)
You're taking the password out of validated_data.

Imagine the request is:

{
"username": "Bob",
"password": "newpassword123"
}

Before pop():

validated_data = {
"username": "Bob",
"password": "newpassword123"
}

After:

password = validated_data.pop("password", None)

you have:

password = "newpassword123"

validated_data = {
"username": "Bob"
}

Why remove it?

Because you don't want the normal:

super().update(...) process to handle the password like an ordinary field.

3. Then this updates the normal fields
user = super().update(instance, validated_data)

At this point, validated_data contains things like:

{
"username": "Bob"
}

4. Then we handle the password ourselves
if password:
user.set_password(password)
user.save()

This is the important part.

Suppose:

password = "newpassword123"

Then:

user.set_password("newpassword123")

turns the plain-text password into a secure hash.

You don't end up with:

password = "newpassword123"
Instead, Django stores something like:

pbkdf2_sha256$...

Then later, when the user logs in:

user.check_password("newpassword123")

Django can verify it.

5. Why super().update() alone isn't enough

This is the really important lesson.

If you had:

def update(self, instance, validated_data):
return super().update(instance, validated_data)

and validated_data contained:

{
"password": "newpassword123"
}

you could end up assigning the raw password directly to the model's password field.

That's not how Django's password system is supposed to work.

fans

📊✅ Master SQL for data science and software engineering.💹 ✅📊The problem was as follows: Report for every three line segm...
17/09/2026

📊✅ Master SQL for data science and software engineering.

💹 ✅📊The problem was as follows: Report for every three line segments whether they can form a triangle.

DESCRIPTION:

Table: Triangle
+-------------+------+
| Column Name | Type |
+-------------+------+
| x | int |
| y | int |
| z | int |
+-------------+------+
In SQL, (x, y, z) is the primary key column for this table.
Each row of this table contains the lengths of three line segments.

Report for every three line segments whether they can form a triangle.

Return the result table in any order.

The result format is in the following example.

Example 1:

Input:
Triangle table:
+----+----+----+
| x | y | z |
+----+----+----+
| 13 | 15 | 30 |
| 10 | 20 | 15 |
+----+----+----+
Output:
+----+----+----+----------+
| x | y | z | triangle |
+----+----+----+----------+
| 13 | 15 | 30 | No |
| 10 | 20 | 15 | Yes |
+----+----+----+----------+

fans

Solution👇

16/09/2026

Javascript exercise for beginners.

📊 ✅ Master SQL for data science and software engineering✅✅📊 The problem was as follows: Write a solution to report the t...
16/09/2026

📊 ✅ Master SQL for data science and software engineering
✅✅📊 The problem was as follows: Write a solution to report the type of each node in the tree.

Description:

Table: Tree
+-------------+------+
| Column Name | Type |
+-------------+------+
| id | int |
| p_id | int |
+-------------+------+
id is the column with unique values for this table.
Each row of this table contains information about the id of a node and the id of its parent node in a tree.
The given structure is always a valid tree.


Each node in the tree can be one of three types:

"Leaf": if the node is a leaf node.
"Root": if the node is the root of the tree.
"Inner": If the node is neither a leaf node nor a root node.
Write a solution to report the type of each node in the tree.

Return the result table in any order.

The result format is in the following example.



Example 1:

Input:
Tree table:
+----+------+
| id | p_id |
+----+------+
| 1 | null |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 2 |
+----+------+
Output:
+----+-------+
| id | type |
+----+-------+
| 1 | Root |
| 2 | Inner |
| 3 | Leaf |
| 4 | Leaf |
| 5 | Leaf |
+----+-------+
Explanation:
Node 1 is the root node because its parent node is null and it has child nodes 2 and 3.
Node 2 is an inner node because it has parent node 1 and child node 4 and 5.
Nodes 3, 4, and 5 are leaf nodes because they have parent nodes and they do not have child nodes.
Example 2:

Input:
Tree table:
+----+------+
| id | p_id |
+----+------+
| 1 | null |
+----+------+
Output:
+----+-------+
| id | type |
+----+-------+
| 1 | Root |
+----+-------+
Explanation: If there is only one node on the tree, you only need to output its root attributes.

fans

Solution👇

Shout out to my newest followers! Excited to have you onboard! Muhammad Iqbal, Wasi Khan, Bezzel Nkosilathi, Mohammad Sa...
15/09/2026

Shout out to my newest followers! Excited to have you onboard! Muhammad Iqbal, Wasi Khan, Bezzel Nkosilathi, Mohammad Saleem, Thiru Babu, Gabriel Barrio, Adeniyi Ogunde, Joseph Ikhile, Juberson Jules Oriol, Muhammad Khaled Mahamud, Nousith Mohd, Silas Lau, Prajith Mathews, Martin Davila Fernandez, Ram Narayanan, Dev Shed, Mohamed Lamri, Mina Adel, En Veasna, Midoban Ryan, Alex Shumoff, Mihai Spandole, Bigg Mohha, Sandri, Bob Gathogo, Castillo Solórzano Jorge Antonio, Alex Silva, Abubakar Abdullahi, Klinton Raj, Oladejo Is-mail Akolawole, Muharrem Öztürk, بن تواتي علي, Dos Chongly, Salem Marei, Joseph Ngumbau, Phương Thùy, Singinadam Jeelakar, Salvatore Lopes, Francisco Javier, Lê Văn Tuấn, Yasmine Belhajyahia, Giri Kathi, Mawadda Mohammed Ahmed, Bibek Kumar, Märōlãhy Lãndríō, Teddy Mahendra Putra, آمنة المتألقة, Arslan Awan, Emanuel Yatipai, Markus Ferrang

15/09/2026

Javascript exercise 💪

📊📈 Master SQL for data science and software engineering.✅📊✅ The problem was as follows: Write a solution to find the peo...
15/09/2026

📊📈 Master SQL for data science and software engineering.

✅📊✅ The problem was as follows: Write a solution to find the people who have the most friends and the most friends number.

Description:

Table: RequestAccepted
+----------------+---------+
| Column Name | Type |
+----------------+---------+
| requester_id | int |
| accepter_id | int |
| accept_date | date |
+----------------+---------+
(requester_id, accepter_id) is the primary key (combination of columns with unique values) for this table.
This table contains the ID of the user who sent the request, the ID of the user who received the request, and the date when the request was accepted.


Write a solution to find the people who have the most friends and the most friends number.

The test cases are generated so that only one person has the most friends.

The result format is in the following example.



Example 1:

Input:
RequestAccepted table:
+--------------+-------------+-------------+
| requester_id | accepter_id | accept_date |
+--------------+-------------+-------------+
| 1 | 2 | 2016/06/03 |
| 1 | 3 | 2016/06/08 |
| 2 | 3 | 2016/06/08 |
| 3 | 4 | 2016/06/09 |
+--------------+-------------+-------------+
Output:
+----+-----+
| id | num |
+----+-----+
| 3 | 3 |
+----+-----+
Explanation:
The person with id 3 is a friend of people 1, 2, and 4, so he has three friends in total, which is the most number than any others.


Follow up: In the real world, multiple people could have the same most number of friends. Could you find all these people in this case?

fans

Solution:👇

Adresse

703 Treanor Avenue
Port-au-Prince
V9B0X7

Notifications

Soyez le premier à savoir et laissez-nous vous envoyer un courriel lorsque DevBridge publie des nouvelles et des promotions. Votre adresse e-mail ne sera pas utilisée à d'autres fins, et vous pouvez vous désabonner à tout moment.

Contacter L'entreprise

Envoyer un message à DevBridge:

Raccourcis

Partager