Default owner to logged in user

This commit is contained in:
Gabriel Augendre 2022-02-28 11:33:57 +01:00
parent 60852475c7
commit f8c7b879b1

View file

@ -24,5 +24,10 @@ class RedirectAdmin(admin.ModelAdmin):
f"{opts.app_label}.{codename}", obj
) or self.has_change_permission(request, obj)
def get_changeform_initial_data(self, request):
get_data = super().get_changeform_initial_data(request)
get_data["owner"] = request.user.pk
return get_data
admin.site.register(RedirectUser, UserAdmin)