0
0
Djangoframework~20 mins

List display configuration in Django - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Django List Display Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What will be displayed in the Django admin list view?
Given this Django admin configuration, what columns will appear in the list view for the Book model?
Django
from django.contrib import admin
from .models import Book

class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'published_date')

admin.site.register(Book, BookAdmin)
AColumns: title, author, published_date
BColumns: title, author only
CColumns: published_date only
DNo columns displayed, default view
Attempts:
2 left
💡 Hint
Check the list_display attribute in the admin class.
📝 Syntax
intermediate
1:30remaining
Identify the syntax error in this list_display configuration
What is wrong with this Django admin list_display setting?
Django
class AuthorAdmin(admin.ModelAdmin):
    list_display = ['name', 'email',]
Alist_display must be a tuple, not a list
BNo syntax error; this is valid Python
CTrailing comma inside list is invalid syntax
DMissing parentheses around list_display
Attempts:
2 left
💡 Hint
Think about Python list syntax and trailing commas.
🔧 Debug
advanced
2:30remaining
Why does this custom method not show in list_display?
This admin class tries to show a custom method in list_display but it does not appear. Why?
Django
class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'author_name')

    @admin.display(description='Author Name')
    def author_name(self, obj):
        return obj.author.name
ACustom methods cannot be used in list_display
Bauthor_name should be a property, not a method
Clist_display must only contain model field names
DThe method author_name lacks the @admin.display decorator
Attempts:
2 left
💡 Hint
Check Django 3.2+ requirements for custom list_display methods.
state_output
advanced
2:00remaining
What is the effect of setting list_display_links to None?
Consider this admin configuration. What happens to the list view links?
Django
class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'pub_date')
    list_display_links = None
ANo fields will be clickable links to the detail page
BAll fields become clickable links
COnly the first field is clickable link
DRaises a TypeError at runtime
Attempts:
2 left
💡 Hint
list_display_links controls which columns link to the edit page.
🧠 Conceptual
expert
3:00remaining
How to optimize list_display for large datasets?
Which approach best improves Django admin list view performance when using list_display with many related fields?
AUse raw SQL queries instead of Django ORM
BDisable pagination to load all items at once
CUse <code>list_select_related</code> to fetch related objects in one query
DAdd all related fields to list_display to avoid extra queries
Attempts:
2 left
💡 Hint
Think about how to reduce database queries in admin list views.