Catalogue: sorting and searching.
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 4 Apr 2022 10:26:51 +0000 (12:26 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 4 Apr 2022 10:26:51 +0000 (12:26 +0200)
src/catalogue/admin.py
src/catalogue/models.py

index 8ce330c..3e80557 100644 (file)
@@ -40,7 +40,12 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
         "priority",
         "wikidata_link",
     ]
         "priority",
         "wikidata_link",
     ]
-    search_fields = ["title", "wikidata", "authors__first_name", "authors__last_name", "translators__first_name", "translators__last_name"]
+    search_fields = [
+        "title", "wikidata",
+        "authors__first_name", "authors__last_name",
+        "translators__first_name", "translators__last_name",
+        "scans_source", "text_source", "notes", "estimate_source",
+    ]
     autocomplete_fields = ["authors", "translators", "based_on", "collections", "epochs", "genres", "kinds"]
     prepopulated_fields = {"slug": ("title",)}
     list_filter = [
     autocomplete_fields = ["authors", "translators", "based_on", "collections", "epochs", "genres", "kinds"]
     prepopulated_fields = {"slug": ("title",)}
     list_filter = [
index 2ceb110..45250bc 100644 (file)
@@ -163,9 +163,11 @@ class Book(WikidataMixin, models.Model):
     
     def authors_str(self):
         return ", ".join(str(author) for author in self.authors.all())
     
     def authors_str(self):
         return ", ".join(str(author) for author in self.authors.all())
+    authors_str.admin_order_field = 'authors__last_name'
 
     def translators_str(self):
         return ", ".join(str(author) for author in self.translators.all())
 
     def translators_str(self):
         return ", ".join(str(author) for author in self.translators.all())
+    translators_str.admin_order_field = 'translators__last_name'
 
     def get_estimated_costs(self):
         return {
 
     def get_estimated_costs(self):
         return {