Fix view on site links in custom admin

Found a Django admin bug!
This commit is contained in:
Stefan Wehrmeyer 2022-03-18 13:44:57 +01:00
parent 4ffdbb0f59
commit 977b13b556

View file

@ -94,6 +94,11 @@ class GovernmentPlanAdmin(admin.ModelAdmin):
)
return qs
def view_on_site(self, obj):
# Avoid Django's redirect through normal admin
# TODO: remove on https://github.com/django/django/pull/15526
return obj.get_absolute_url()
def get_actions(self, request):
actions = super().get_actions(request)
if not has_limited_access(request.user):
@ -205,6 +210,11 @@ class GovernmentPlanUpdateAdmin(admin.ModelAdmin):
qs = qs.filter(plan__in=get_allowed_plans(request))
return qs
def view_on_site(self, obj):
# Avoid Django's redirect through normal admin
# TODO: remove on https://github.com/django/django/pull/15526
return obj.get_absolute_url()
def save_model(self, request, obj, form, change):
limited = has_limited_access(request.user)
if not change and limited: