Package: django-admin-extra-urls
Pluggable django application that offers one single mixin classExtraUrlMixinto easily add new url (and related buttons on the screen) to any ModelAdmin.url()decorator will create a new view for the ModelAdmin.button()shortcut forurl(button={...}).link()to add button that point to external urls.Installpipinstalldjango-admin-extra-urlsAfter installation add it toINSTALLED_APPSINSTALLED_APPS=(...'admin_extra_urls',)How to use itfromadmin_extra_urls.apiimporturl,button,link,hrefclassMyModelModelAdmin(extras.ExtraUrlMixin,admin.ModelAdmin):@link(label='Search On Google','http://www.google.com?q={target}')# /admin/myapp/mymodel/update_all/defsearch_on_google(self,button):# this is called by the template engine just before rendering the button# `context` is the Context instance in the templateif'original'inbutton.context:obj=button.context['original']return{'target':obj.name}else:button.visible=False@link()defsearch_on_bing(self,button):return'http://www.bing.com?q=target'@button()# /admin/myapp/mymodel/update_all/defconsolidate(self,request):......@button()# /admin/myapp/mymodel/update/10/defupdate(self,request,pk):# if we use `pk` in the args, the button will be in change_formobj=self.get_object(request,pk)...@button(urls=[r'^aaa/(?P<pk>.*)/(?P<state>.*)/$',r'^bbb/(?P<pk>.*)/$'])defrevert(self,request,pk,state=None):obj=self.get_object(request,pk)...@button(label='Truncate',permission=lambdarequest,obj:request.user.is_superuser)deftruncate(self,request):ifrequest.method=='POST':self.model.objects._truncate()else:returnextras._confirm_action(self,request,self.truncate,'Continuing will erase the entire content of the table.','Successfully executed',)If the return value from abuttondecorated method is a HttpResponse, that will be used.  Otherwise if the method contains thepkargument user will be redirected to the ‘update’ view, otherwise and the browser will be redirected to the admin’s list viewbutton()optionsThese are the arguments thatbutton()acceptspathNonepathurl path for the button. Will be the url where the button will point to.labelNoneLabel for the button. By default the “labelized” function name.icon‘’Icon for the button.permissionNonePermission required to use the button. Can be a callable (current object as argument).css_class“btn btn-success”Extra css classes to use for the buttonorder999In case of multiple button the order to usevisiblelambda o: o and o.pkcallable or bool. By default do not display “action” button if inaddmodeurlsNonelist of urls to be linked to the action.Integration with other librariesdjango-import-export@admin.register(Rule)classRuleAdmin(ExtraUrlMixin,ImportExportMixin,BaseModelAdmin):@button(label='Export')def_export(self,request):if'_changelist_filters'inrequest.GET:real_query=QueryDict(request.GET.get('_changelist_filters'))request.GET=real_queryreturnself.export_action(request)@button(label='Import')def_import(self,request):returnself.import_action(request)Running project tests locallyInstall the dev dependencies withpip install-e'.[dev]'and then run tox.LinksStableDevelopmentProject home page:https://github.com/saxix/django-admin-extra-urlsIssue tracker:https://github.com/saxix/django-admin-extra-urls/issues?sortDownload:http://pypi.python.org/pypi/admin-extra-urls/