Message from discussion
How to overwrite the hyperlink of objects in change list template of django admin?
Received: by 10.114.144.1 with SMTP id r1mr2872106wad.17.1208137401708;
Sun, 13 Apr 2008 18:43:21 -0700 (PDT)
Return-Path: <malc...@pointy-stick.com>
Received: from tallyho.bytemark.co.uk (tallyho.bytemark.co.uk [80.68.81.166])
by mx.google.com with ESMTP id k36si7307863waf.1.2008.04.13.18.33.41;
Sun, 13 Apr 2008 18:43:21 -0700 (PDT)
Received-SPF: neutral (google.com: 80.68.81.166 is neither permitted nor denied by best guess record for domain of malc...@pointy-stick.com) client-ip=80.68.81.166;
Authentication-Results: mx.google.com; spf=neutral (google.com: 80.68.81.166 is neither permitted nor denied by best guess record for domain of malc...@pointy-stick.com) smtp.mail=malc...@pointy-stick.com
Received: from sharp.pointy-stick.com ([80.68.90.23])
by tallyho.bytemark.co.uk with esmtp (Exim 4.63)
(envelope-from <malc...@pointy-stick.com>)
id 1JlDPm-0004sB-6j
for django-users@googlegroups.com; Mon, 14 Apr 2008 01:23:22 +0000
Received: from [192.168.0.102] (cust7071.nsw01.dataco.com.au [203.171.88.159])
by sharp.pointy-stick.com (Postfix) with ESMTP id 6E1D1C406
for <django-users@googlegroups.com>; Mon, 14 Apr 2008 11:23:19 +1000 (EST)
Subject: Re: How to overwrite the hyperlink of objects in change list
template of django admin?
From: Malcolm Tredinnick <malc...@pointy-stick.com>
To: django-users@googlegroups.com
In-Reply-To: <3ca3f9dd-63c0-417c-82ad-7bd290114083@t12g2000prg.googlegroups.com>
References:
<3ca3f9dd-63c0-417c-82ad-7bd290114...@t12g2000prg.googlegroups.com>
Content-Type: text/plain
Date: Mon, 14 Apr 2008 11:23:09 +1000
Message-Id: <1208136189.27246.3.camel@counterweight.tredinnick.org>
Mime-Version: 1.0
X-Mailer: Evolution 2.12.3 (2.12.3-3.fc8)
Content-Transfer-Encoding: 7bit
On Sun, 2008-04-13 at 06:20 -0700, Leon wrote:
> Hi,
> I use django admin to manage a table. There is a hyperlink for
> each object in the change_list template, which will bring me to the
> change_form template. I want to change that hyperlink and redirect it
> to another url to handle. I didn't want to customize the current
> change_form for this model because it is still used somewhere else.
> Anybody knows how to do it?
It's possible, but fairly fiddly. You can create a custom
change_list.html template for just that application + model name
combination (since the admin interface tries to load a template under
admin/<app_name>/<model_name>/change_list.html as one of the options for
that page). Then you need to write a template that displays what you
would like, which possibly means duplicating a lot of the logic of the
original page and the template tags that construct it. With a bit of
tracing through the code (admin/templates/admin/change_list.html,
admin/tempates/admin/change_list_result.html,
admin/templatetags/admin_list.py, admin/views/main.py) it should be
quite possible to achieve what you want. Take your time and you'll get
there (or use newforms-admin or wait for newforms-admin to be merged
into trunk, both of which will be easier).
Note that this sort of customisation does require you to read some
Python code and templates and do a bit of design work. There isn't a
step-by-step guide, so if you aren't up to being able to read the code a
bit, this probably isn't the right sort of customisation to be trying to
make.
Regards,
Malcolm
--
Tolkien is hobbit-forming.
http://www.pointy-stick.com/blog/