from django.contrib import admin

from .models import JoinInvitation, InvitationStat


class InvitationStatAdmin(admin.ModelAdmin):
    raw_id_fields = ["user"]
    readonly_fields = ["invites_sent", "invites_accepted"]
    list_display = [
        "user",
        "invites_sent",
        "invites_accepted",
        "invites_allocated",
        "invites_remaining",
        "can_send"
    ]
    list_filter = ["invites_sent", "invites_accepted"]


admin.site.register(
    JoinInvitation,
    list_display=["from_user", "to_user", "sent", "status", "to_user_email"],
    list_filter=["sent", "status"],
    search_fields=["from_user__username"]
)
admin.site.register(InvitationStat, InvitationStatAdmin)

@@ -25,16 +25,63 @@
 rt admin
+%0Afrom django.contrib.auth import get_user_model
 %0A%0Afrom .
@@ -127,16 +127,42 @@
 nStat%0A%0A%0A
+User = get_user_model()%0A%0A%0A
 class In
@@ -705,17 +705,39 @@
 er__
-username%22
+%7B%7D%22.format(User.USERNAME_FIELD)
 %5D%0A)%0A

don't assume AUTH_USER_MODEL USERNAME_FIELD is username