Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 30, 2005 10:40:09

[EMAIL P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Customising new-admin tags


Hi

I know this has been talked about before but I'm having real trouble
getting a handle on customising template tags

What i want to do is alter the admin change list screen to show some
related values. Now the python's easy it's just a couple of lines in
items_for_results in admin_list.py problem is I only want to do this
for certain modules in a certain app not for everything

What's confusing me is where I can put my custom code so that it will
work, all my attemps so far just kill django without retuning any
errors

Please help

Charlie

Offline

#2 Nov. 30, 2005 16:45:02

Robert W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Customising new-admin tags


wrote:
> Hi
>
> I know this has been talked about before but I'm having real trouble
> getting a handle on customising template tags
>
> What i want to do is alter the admin change list screen to show some
> related values. Now the python's easy it's just a couple of lines in
> items_for_results in admin_list.py problem is I only want to do this
> for certain modules in a certain app not for everything
>
> What's confusing me is where I can put my custom code so that it will
> work, all my attemps so far just kill django without retuning any
> errors
>
> Please help
>
> Charlie
>
>

If you want to customise the changelist, your best bet is to subclass
the ChangeList class.

If the template tags are doing 'too much', they should probably be
changed to delegate more to the ChangeList class.

Offline

#3 Nov. 30, 2005 17:25:13

oggie r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Customising new-admin tags


Hi Charlie,
You should probably put your custom code in the views.py file, and put
custom templates under your specified templates directory (the
templates should match the URL you are going for).
So from what I can gather this would be:
'TEMPLATES/admin/polls/poll/change_form.html' where TEMPLATES is the
directory that you specify in your settings.py file. (NOTE: module name
is singular!)
Also the template might contain something like:
{% extends 'admin/change_form' %}
{% block after_related_objects %}
<P>
Here is my extra content
</P>
{% endblock %}

Now, that was the easy part :)

Unfortunately, the admin interface does not yet allow you to easily
extend the information that is used in places like the change_form.
Your best bet for now is probably to copy and paste the change_stage()
and add_stage() method for your own modules. You can then override
these in the urls.py file.
e.g.

(r'^admin/(?P<app_label>+)/(?P<module_name>(polls|choices|myotheroverriddenmodule))/(?P<object_id>.+)/$',
'polls.apps.polls.views.override_change')


Note that I don't really think this is an ideal solution, but I've been
struggling with this problem for the last several days and for me this
seemed the best approach. Hopefully soon we'll have some way to more
easily extend the admin manipulators.

-rob

Offline

Board footer

Moderator control

Enjoy the 27th of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support