简体   繁体   中英

django admin redirecting to custom view

In my admin.py I have done..

class MediaManagerAdmin(admin.ModelAdmin):

def get_urls(self):
    urls = super(MediaManagerAdmin, self).get_urls()
    print "some"
    my_urls = [
        url(r'^mediacontrol/',self.my_view),
    ]
    return my_urls + urls
    print "helloww"

def my_view(self,request):
    return render_to_response("anything.html")
admin.site.register(MediaManager, MediaManagerAdmin)

Here what I want is in admin when I click the MediaManager table it should redirect to my custom url url(r'^mediacontrol/',self.my_view), with my custom view and template.

But its not redirecting to this url. It is redirecting to the usual admin url. Nothing is changing same like regular admin.

How can I redirect a table to my custom view and template in admin.

Need help

Set the regex for your view to the empty string:

my_urls = [
    url(r'^$', self.my_view),
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM