admin: Use autocomplete for user field

Before this patch, we used the default setting, which emits a HTML
<select> tag containing a list of *all* the users.  We currently
have enough users that we do not want to load that complete list
every time.  So now, use the autocomplete field instead.
This commit is contained in:
Daan Sprenkels
2020-06-15 17:34:20 +02:00
parent 1a797a5d98
commit 64b26d03a1
2 changed files with 4 additions and 0 deletions

View File

@ -12,8 +12,10 @@ class OrderAdmin(admin.ModelAdmin):
@admin.register(PlaylistSong)
class PlaylistSongAdmin(admin.ModelAdmin):
list_display = ('playlist', 'song', 'user', 'state', 'played_at')
list_display_links = ('song',)
list_filter = ('playlist', 'state', 'user')
search_fields = ('song__title', 'song__artist', 'user__name')
autocomplete_fields = ('user',)
readonly_fields = ('song',)

View File

@ -14,6 +14,7 @@ class SongAdmin(admin.ModelAdmin):
list_display = ('artist', 'title', 'user_name', 'reports')
search_fields = ('artist', 'title', 'user__name')
inlines = [ReportNoteInline]
autocomplete_fields = ('user',)
@staticmethod
def reports(song):
@ -35,6 +36,7 @@ class ReportNoteAdmin(admin.ModelAdmin):
exclude = ('song',)
list_display = ('song', 'note', 'user')
search_fields = ('song__artist', 'song__title', 'user__name')
autocomplete_fields = ('user',)
readonly_fields = ('song_link',)
@staticmethod