S
S
Shporsoft2020-09-28 16:31:14
Django
Shporsoft, 2020-09-28 16:31:14

How to make (and output) an image from text in django?

For example, I have an article model. It has fields: title(CharField), thumbnail(ImageField, blank=True). When the user does not want to upload a picture, it is necessary to create a picture with the title of the article. If it is not clear, you can see the illustration:
5f71e546dfc32286539696.png
Is it possible to implement this? Z.Y. pay no attention to what is written below. This is for clarity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-09-28
@Shporsoft

Maybe. Hang up a pre_save signal to save the article, check in the signal handler that the image field is not set, get the title text, use Pillow to create a picture and assign the image field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question