Course Content
Django: First Dive
Django: First Dive
2. Write the First Page
4. Working with Database
Challenge: 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 theSubmit Task
button to solve this task.
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |
Everything was clear?
Challenge: 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 theSubmit Task
button to solve this task.
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |
Everything was clear?
Challenge: 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 theSubmit Task
button to solve this task.
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |
Everything was clear?
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 theSubmit Task
button to solve this task.
Task
You have already implemented Model class:
Write 5 view functions:
dog_list(request)
should display the list of dogs on the HTML page like following:dog_get(request, pk)
should display the information about the selected Dog bypk
(id
).dog_create(request)
should create the new Dog with the name"Unknown"
, age0
, and weight1.1
.dog_update(request, pk)
should update theDog
's name to"Updater"
,age += 1
, andweight += 0.2
.dog_delete(request, pk)
should delete the existing dog byid
.
Connect views to URLs
URL | View |
dogs/ | dog_list |
dogs/id/ | dog_get |
dogs/id/update/ | dog_update |
dogs/id/delete/ | dog_delete |
dogs/create/ | dog_create |