Challenge - 5 Problems
Django List Display Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2: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)
Attempts:
2 left
💡 Hint
Check the
list_display attribute in the admin class.✗ Incorrect
The list_display tuple defines which fields show as columns in the admin list view. Here, it includes 'title', 'author', and 'published_date'.
📝 Syntax
intermediate1: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',]
Attempts:
2 left
💡 Hint
Think about Python list syntax and trailing commas.
✗ Incorrect
In Python, lists can have trailing commas without error. Using a list or tuple for list_display is allowed.
🔧 Debug
advanced2: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
Attempts:
2 left
💡 Hint
Check Django 3.2+ requirements for custom list_display methods.
✗ Incorrect
Since Django 3.2, custom methods in list_display should use the @admin.display decorator to work properly.
❓ state_output
advanced2: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
Attempts:
2 left
💡 Hint
list_display_links controls which columns link to the edit page.
✗ Incorrect
Setting list_display_links = None disables all clickable links in the list view.
🧠 Conceptual
expert3: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?
Attempts:
2 left
💡 Hint
Think about how to reduce database queries in admin list views.
✗ Incorrect
list_select_related tells Django to use SQL joins to fetch related objects in one query, improving performance.