开发者

How to extend an ImageField in my own django admin template?

开发者 https://www.devze.com 2022-12-19 09:37 出处:网络
I would like to make a custom admin page for one of my application with django. I\'ve created a change_form.html and fieldset.html in admin/myapp/mymodel of my template folder. I am now able to custom

I would like to make a custom admin page for one of my application with django. I've created a change_form.html and fieldset.html in admin/myapp/mymodel of my template folder. I am now able to customize the page.

mymodel has an ImageField and I would like to display this image on the page. I guess this is possible because the ImageField shows a link to the image on the page.

I am trying to modify the fieldset.html but unfortunately I don't know how to access the url in order to put in an img html tag. {{field.field.field}}开发者_运维问答 shows an ImageField object but how to access the current value for this field?

Thanks in advance


<img src="{{field.field.field.url}}"> 

On a related note, instead of having to do all that, you could use django-form-utils that will provide you a thumbnail included display and clear-able file field, for free.


The current object can be accessed in a custom django admin template with {{original}}

It solves my problem

0

精彩评论

暂无评论...
验证码 换一张
取 消