2👍
✅
You should override the change_view
method of the ModelAdmin
, like this:
from django.contrib import admin
from django.shortcuts import redirect
from yourapp.models import Product
class ProductAdmin(admin.ModelAdmin):
def change_view(request, object_id, form_url='', extra_context=None):
return redirect(
"admin:yourapp_offer_change",
args=(Product.objects.get(pk=object_id).offer.pk,)
)
admin.site.register(Product, ProductAdmin)
Replace yourapp
with the name of the Django application in which you have your Offer
and Product
models.
Source:stackexchange.com