At least a couple of times I needed to add additional links in a
changelist page (like "Add Item+"). So I tweaked admin code to accept
"object_tool_links" attribute in model's Admin class where I specify a
3-tuple (link_text, link_href, classes) eg.
('Clean Up', 'cleanup/', 'customlink someotherclass')
Of course now every time I svn update it goes away, so I was thinking I
ask here first if it was worth submitting a ticket+patch.
Cheers,
Andrius
Looking at my ticket again, I am thinking it would be better to put the
block tag in the admin/base_site.html template, that way any other page
extending admin/base_site.html could add custom object tools instead of
just the change_list page.
As for your suggestion, what if you wanted to put object tools on the
change_form page too? It's starts to get messy with adding Admin class
attributes for each of the pages. Probably more elegantly handled in
the templates.
I meant admin/base.html. Added new and improved patch to ticket.
On Dec 20, 6:39 am, "Gary Wilson" <gary.wil...@gmail.com> wrote:
> Gary Wilson wrote:
> > Looking at my ticket again, I am thinking it would be better to put the
> > block tag in the admin/base_site.html template, that way any other page
> > extending admin/base_site.html could add custom object tools instead of
> > just the change_list page.I meant admin/base.html. Added new and improved patch to ticket.
>
> http://code.djangoproject.com/ticket/3128
> <model>_change_list.html instead of original one. If it somehow did the
> same like with generic views where it looks for a <model>_detail.html
> but loads a default detail.html if former does not exist.
+1 from me.
This would be great. But I think it would be better to name the
templates <app>_<model>_foo.html. It would make the customization of
admin pages very easy and Django-like.
> This would be great. But I think it would be better to name the
> templates <app>_<model>_foo.html. It would make the customization of
> admin pages very easy and Django-like.
D'oh. After looking the admin source code, this allready works! I
wonder howcome it isn't documented? (Or is it?)
Anyway, you can override the default admin template (at least for
change_list.html and change_form.html) by putting your own template to
/yourtemplates/admin/<appname>/ for app-wide override or to
/yourtemplates/admin/appname/modelname/ for model-wide override,
respectively.
This is great. And I really think it should be better documented! :)
Yeah, the only place I know of is:
http://code.djangoproject.com/wiki/NewAdminChanges#Adminconvertedtoseparatetemplates