简体   繁体   中英

Add Derived Field to Django Admin Change Form

I'd like to add a derived field to a default ModelAdmin.fieldsets like I would by specifying a method and adding it to the ModelAdmin.list_display property, but there doesn't seem to be an easy way to do that (if there is ANY way to do that).

The default Django Admin list view seems to have a lot more options than the change form view does.

Let's say I have two fields for a location: latitude and longitude, and instead of displaying them on a change form I want to display a Google Maps Static Map image instead - I already have a method that will return the src url for the image - I just need a way to add that image to the model change form instead of showing those two fields.

如果您编写方法并将其添加到ModelAdmin.readonly_fields,它将显示在更改视图中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM