views:

50

answers:

2

Hi everybody, I want to change the shape of some fields showed in the admin site.

I found that the template that manage everything is change_form.html with fieldset.html but I cannot find where the fields are actually transformed in html.

Basically I want to change the field of the foreign key adding a link to another page.

Do you have any idea?

Thanks, Giovanni

+1  A: 

The HTML for a given field is handled by its widget in the render function. If you want to customize the look of a field you could create a custom widget which has the additional HTML you need in the render.

You can check out the render some of the built in widgets in django/forms/widgets.py (links to the Django trunk).

Mark Lavin
thank you very much!
Giovanni Di Milia
A: 

In fieldset.html, the code {{ field.field }} renders the field's HTML representation. to achieve what you want, you'll probably need to define your own widget. you can take a look at admin's widgets.py

Ofri Raviv