Hide quota field when adding new users

pull/1559/head
Piero Toffanin 2024-09-28 19:36:46 -04:00
rodzic 9ee1474df7
commit b9868baa3d
1 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -268,9 +268,19 @@ class ProfileInline(admin.StackedInline):
model = Profile
can_delete = False
# Hide "quota" profile field when adding (show during editing)
def get_fields(self, request, obj=None):
if obj is None:
fields = list(super().get_fields(request, obj))
fields.remove('quota')
return fields
else:
return super().get_fields(request, obj)
class UserAdmin(BaseUserAdmin):
inlines = [ProfileInline]
# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)