Abhilash Nanda
Abhilash Nanda

Reputation: 359

Django Admin: Change URL links in change_list page

I would like to change the URL links in the change_list page from default to something else.

I have gone through the code of Admin and have to say, I need help.

Can anyone help me out??? enter image description here

Example: In the above pic, I want to change the link under "Abhilash Nanda" to some other link. This for all the rows I may have. I would like to go from this change list page to another change list page where I can again list the rows from a related table to the clicked link.

Upvotes: 0

Views: 2962

Answers (1)

Edwin Lunando
Edwin Lunando

Reputation: 2816

You can edit the admin URL by extending the admin model. Like this.

class MyModelAdmin(admin.ModelAdmin):
    def get_urls(self):
        urls = super(MyModelAdmin, self).get_urls()
        my_urls = patterns('',
            (r'^my_view/$', self.my_view)
        )
        return my_urls + urls

    def my_view(self, request):
        # custom view which should return an HttpResponse
        pass

You can here the full documentation here.

Upvotes: 1

Related Questions