Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: CRUD with Person | Working with Database
Django: First Dive
セクション 4.  4
single

single

bookChallenge: CRUD with Person

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

Note

The presented code for the task is part of the framework and cannot work separately, so errors will be received when you try to Run Code. Use the Submit Task button to solve this task.

タスク

スワイプしてコーディングを開始

You have already implemented Model class:

class Dog(models.Model):
    name = models.CharField(max_length=30)
    age = models.IntegerField()
    weight = models.FloatField()

    object = models.Manager()

Write 5 view functions:

  1. dog_list(request) should display the list of dogs on the HTML page like following:

    <h1>Dog {id}</h1>
    <p>Name: {name}</p>
    <p>Age: {age}</p>
    <p>Weight: {weight}</p>
    
  2. dog_get(request, pk) should display the information about the selected Dog by pk (id).

  3. dog_create(request) should create the new Dog with the name "Unknown", age 0, and weight 1.1.

  4. dog_update(request, pk) should update the Dog's name to "Updater", age += 1, and weight += 0.2.

  5. dog_delete(request, pk) should delete the existing dog by id.

Connect views to URLs

URLView
dogs/dog_list
dogs/id/dog_get
dogs/id/update/dog_update
dogs/id/delete/dog_delete
dogs/create/dog_create

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

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

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

セクション 4.  4
single

single

AIに質問する

expand

AIに質問する

ChatGPT

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

some-alt