Optimize member autocomplete by using indexes and istartswith
This commit is contained in:
parent
1eb3952ea1
commit
b48c723bc4
@ -20,7 +20,7 @@ class MemberFlagInline(admin.TabularInline):
|
|||||||
|
|
||||||
@admin.register(Member)
|
@admin.register(Member)
|
||||||
class MemberAdmin(ReadOnlyAdmin):
|
class MemberAdmin(ReadOnlyAdmin):
|
||||||
search_fields = ["account_name"]
|
search_fields = ["^first_name", "^last_name", "^account_name"]
|
||||||
inlines = [MemberFlagInline]
|
inlines = [MemberFlagInline]
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,6 +163,11 @@ class Member(models.Model):
|
|||||||
managed = False
|
managed = False
|
||||||
db_table = "members"
|
db_table = "members"
|
||||||
ordering = ("first_name", "last_name")
|
ordering = ("first_name", "last_name")
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["account_name"]),
|
||||||
|
models.Index(fields=["first_name"]),
|
||||||
|
models.Index(fields=["last_name"]),
|
||||||
|
]
|
||||||
|
|
||||||
def sanitized_mailbox(self, name_ext: str = "", use_volunteer=False) -> str:
|
def sanitized_mailbox(self, name_ext: str = "", use_volunteer=False) -> str:
|
||||||
if use_volunteer and self.volunteer_email:
|
if use_volunteer and self.volunteer_email:
|
||||||
|
Loading…
Reference in New Issue
Block a user