0
0
Djangoframework~10 mins

Registering models in admin 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 register the model Book in the Django admin site.

Django
from django.contrib import admin
from .models import Book

admin.site.[1](Book)
Drag options to blanks, or click blank then click option'
Ainclude
Bunregister
Cadd
Dregister
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'unregister' instead of 'register'.
Trying to use 'add' or 'include' which are not valid methods.
2fill in blank
medium

Complete the code to import the Author model from the current app's models.

Django
from .models import [1]
Drag options to blanks, or click blank then click option'
ABook
BCategory
CAuthor
DPublisher
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong model name.
Forgetting to import the model before registering.
3fill in blank
hard

Fix the error in the code to properly register the Publisher model in admin.

Django
from django.contrib import admin
from .models import Publisher

admin.site.[1](Publisher)
Drag options to blanks, or click blank then click option'
Aregister
Bregisters
CRegister
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'registers' instead of 'register'.
Capitalizing the method name.
4fill in blank
hard

Fill both blanks to register the Category model with a custom admin class CategoryAdmin.

Django
from django.contrib import admin
from .models import Category

admin.site.[1](Category, [2])
Drag options to blanks, or click blank then click option'
Aregister
Bunregister
CCategoryAdmin
DCategoryAdminClass
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'unregister' instead of 'register'.
Using the wrong admin class name.
5fill in blank
hard

Fill all three blanks to register the Article model with a custom admin class ArticleAdmin and import it correctly.

Django
from django.contrib import admin
from .models import [1]

admin.site.[2]([3], ArticleAdmin)
Drag options to blanks, or click blank then click option'
AArticle
Bregister
DAuthor
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong model.
Using the wrong method name.
Mismatching model names in import and register.