0
0
Djangoframework~10 mins

DeleteView for removal in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the generic DeleteView class from Django.

Django
from django.views.generic import [1]
Drag options to blanks, or click blank then click option'
ACreateView
BListView
CDeleteView
DUpdateView
Attempts:
3 left
💡 Hint
Common Mistakes
Importing ListView instead of DeleteView
Using CreateView or UpdateView which are for other purposes
2fill in blank
medium

Complete the code to specify the model to delete in a DeleteView subclass.

Django
class BookDeleteView(DeleteView):
    model = [1]
Drag options to blanks, or click blank then click option'
AReview
BAuthor
CPublisher
DBook
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different model name than the view's purpose
Forgetting to set the model attribute
3fill in blank
hard

Fix the error in the DeleteView by completing the code to redirect after deletion.

Django
class BookDeleteView(DeleteView):
    model = Book
    success_url = [1]
Drag options to blanks, or click blank then click option'
A'/books/'
Breverse('book-list')
Credirect('book-list')
Drender('book-list.html')
Attempts:
3 left
💡 Hint
Common Mistakes
Using reverse() directly without lazy evaluation
Using redirect() or render() which are not valid here
4fill in blank
hard

Fill both blanks to complete the URL pattern for the DeleteView.

Django
path('[1]/<int:pk>/delete/', [2].as_view(), name='book-delete')
Drag options to blanks, or click blank then click option'
Abooks
BBookDeleteView
Cbook
DBookListView
Attempts:
3 left
💡 Hint
Common Mistakes
Using plural 'books' in URL when singular is expected
Using wrong view class like BookListView
5fill in blank
hard

Fill all three blanks to complete the DeleteView with template name and success URL.

Django
class BookDeleteView(DeleteView):
    model = [1]
    template_name = '[2]'
    success_url = '[3]'
Drag options to blanks, or click blank then click option'
ABook
Bbooks/book_confirm_delete.html
C/books/
DAuthor
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong model name
Incorrect template path
Wrong success URL path