Daniel,
I did read the docs and could not get it to work. Probably operator error,
as I went back a day later and followed the docs, and it worked as
advertised!
In the interest of completeness, here are the snippets of what I did:
class DocumentMetaDataAdmin(admin.ModelAdmin):
readonly_fields = ('get_image_2', )
fieldsets = (
(None, {
'fields': ('get_image_2', ),
'classes': ('extrapretty', ),
}),
)
def get_image_2(self, obj):
image = "" # need to add a default image
if (obj.document_id.storage_file_name):
image = '<a href="{image_link}"><img src="{thumb_nail}"
style="height:400px"/></a>'.format(image_link =
obj.document_id.storage_file_name.url, thumb_nail =
obj.document_id.storage_file_name.url)
return format_html(image)
Thanks!
Mark
PS Still working on defining the 'extrapretty' CSS!
On Wed, Jun 6, 2018 at 5:17 AM, Daniel Germano Travieso <
[email protected]> wrote:
> Hello Mark.
>
> You can just override the Model Admin for your model and insert an Inline
> Form for example.
>
> Check the documentation for customizing the model admin!
>
> Hope it helps!
>
>
> On Mon, Jun 4, 2018, 18:02 Mark Phillips <[email protected]>
> wrote:
>
>> I have a Document model that uploads an image. I have a DocumentMetaData
>> model with a JSON field where I "crud" metadata for the documents in the
>> Document model.
>>
>> I would like to add the image of the document in the Document model to
>> the change form of the DocumentMetaData model in the admin. How do I do it?
>> Do I have to override the admin/change_form.html for the DocumentMetaData
>> model?
>>
>> Thanks!
>>
>> Mark
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/CAEqej2PYNudeSWa5CY934m8kMWO%
>> 3Dhcpj4%3DxQud9C-wZCHoaS4g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAEqej2PYNudeSWa5CY934m8kMWO%3Dhcpj4%3DxQud9C-wZCHoaS4g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CABF8kZOWiPDeDrtTbuytOD8Nm%
> 3DHqd1A%2BtwNKSkmmEyk85jVGzA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CABF8kZOWiPDeDrtTbuytOD8Nm%3DHqd1A%2BtwNKSkmmEyk85jVGzA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAEqej2MG8f2kV5W68tYdgyYGm0d2Lr_O9ieKVOoNY%2BK8SKEP7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.