views:

176

answers:

1

I have a Doctor-model which has a field called first_created. It is just a DateField that is auto_add_now, hence it is not displayed when editing a doctor in the admin interface.

I want to display this field on the admin interface, at the top of the site as say, a static or something. It is supposed to ease the process of typing in data in other fields, so a sentence like "three months from now" will make more sense.

Since the model should according to the documentation, should hold all model fields as template variables, I am trying to overwrite the change_form.html and outputting {{ doctor.first_created }}. But it is not working.

I've tried multiple things, even things like looping over opts.fields and printing out methods on these fields like value_to_string. Not working.

How can I print first_created as a template variable in change_form.html?

Regards

+1  A: 

You haven't said what doctor is in the context of the edit page. Is it the object being edited? That's passed to the template as original, so you should be able to do {{ original.first_created }}.

Daniel Roseman
This was exactly what I wanted. Had not seen this anywhere in the documentation. Thanks alot.
John Magistr
No, it's not in the documentation - but the advantage of open source is that you can read the code.
Daniel Roseman