Customizable object tools

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Customizable object tools

ao-2

Hi,

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


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Customizable object tools

Gary Wilson Jr.

FYI, I filed a ticket [1] about this same topic last week, but I was
asking for an extra block tag in the change_list template.  I am
assuming that you are also putting the object_tool_links on the
change_list page?

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.

[1] http://code.djangoproject.com/ticket/3128


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Customizable object tools

Gary Wilson Jr.

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


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Customizable object tools

ao-2

I saw your ticket got patched and changed my code to use templates for
extended object tools. Works great but still gets a bit messy when i
have to create new template file for each model I want to have one
extra link and then write code to load that custom
<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.


On Dec 20, 6:39 am, "Gary Wilson" <[hidden email]> 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


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Customizable object tools

Ville Säävuori

ao wrote:

> <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.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Customizable object tools

Ville Säävuori

Replying to myself

> 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! :)


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Customizable object tools

Gary Wilson Jr.

Ville Säävuori wrote:

> Replying to myself
>
> > 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


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---