Home:ALL Converter>how to create link in django admin to custom django admin url?

how to create link in django admin to custom django admin url?

Ask Time:2017-07-18T23:08:48         Author:user2604098

Json Formatter

how to create link in django admin to custom django admin url i have 2 apps in django admin and i want to link from app1 to custom url in app 2

admin.py APP1

class APP1Admin(ModelAdmin):
    list_display = ('xx','request_me')

    def request_me(self,obj):

       reverse_path = reverse("admin: APP2_TargetLink",args=(obj.pk,)) # My Problem is  How to link to func APP2 target link

       return '<a href="%s"> link </a>'%(reverse_path)

    request_me.allow_tags =True

admin.py APP2

class APP2Admin(ModelAdmin):

   def get_urls(self):
       urls = super(APP2Admin, self).get_urls()
       my_urls = [
       url(r'(\d*)/target_link/$', self.admin_site.admin_view(self.target_link_view),name="TargetLink"),
    ]
      return my_urls + urls

    def target_link_view(self,request,id):
       ...
       return TemplateResponse(request, template, context)

Author:user2604098,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45170667/how-to-create-link-in-django-admin-to-custom-django-admin-url
yy