R
R
Roman Alexandrov2020-05-22 22:00:06
Django
Roman Alexandrov, 2020-05-22 22:00:06

How to display BinaryField in django admin panel as ImageField?

I have a screenshot model

class Screenshot(models.Model):
    project = models.ForeignKey(Project, on_delete=models.CASCADE)
    screen = models.BinaryField(editable=True)


I want to make it so that the image is stored in the database,
but at the same time in the admin panel I saw it as an image.

I searched and found this question
https://stackoverflow.com/questions/46692520/how-t...

But when I tried to use this, I didn't get a field to select a file

5ec81f1be129a368812335.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-05-22
@bacon

Output as an img tag, in src specify data:url collected from this BinaryField

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question