from django.contrib import admin
from . import models
+from .wikidata import WikidataAdminMixin
+class AuthorAdmin(WikidataAdminMixin, admin.ModelAdmin):
+ list_display = "first_name", "last_name", "notes"
+ search_fields = ["first_name", "last_name", "wikidata"]
+ prepopulated_fields = {"slug": ("first_name", "last_name")}
-class AuthorAdmin(admin.ModelAdmin):
- search_fields = ['name']
admin.site.register(models.Author, AuthorAdmin)
-class BookAdmin(admin.ModelAdmin):
- raw_id_fields = ['authors']
- autocomplete_fields = ['translators']
+class BookAdmin(WikidataAdminMixin, admin.ModelAdmin):
+ list_display = "title", "notes"
+ autocomplete_fields = ["authors", "translators"]
+ prepopulated_fields = {"slug": ("title",)}
-admin.site.register(models.Book, BookAdmin)
+admin.site.register(models.Book, BookAdmin)