Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Updating | Queries
Django ORM Ninja: Advanced Techniques for Developers

bookUpdating

メニューを表示するにはスワイプしてください

To update specific information of an object in our table, we first need to retrieve that object, commonly using the get method:

author_3 = Author.objects.get(id=3)

Now, let's say we want to update the pen name of this author. We first access the current attributes:

print(author_3.first_name)  # -> "James"
print(author_3.last_name)  # -> "Clear"
print(author_3.pen_name)  # -> ""

Let's imagine that we want to update the pen_name of our 3-d author.

To update the pen name to "James Clear", we assign the new value and save the object:

author_3.pen_name = "James Clear"
author_3.save()

And that's essentially it for updating an object.

1. Before updating an object in Django, what is the recommended first step?

2. How do you update the 'pen_name' attribute of an Author object in Django?

3. What must you do after changing an attribute of a Django object to persist the update?

question mark

Before updating an object in Django, what is the recommended first step?

正しい答えを選んでください

question mark

How do you update the 'pen_name' attribute of an Author object in Django?

正しい答えを選んでください

question mark

What must you do after changing an attribute of a Django object to persist the update?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 3.  5

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 3.  5
some-alt