3๐
โ
I found out what to do:
In my model I added the following (I use a model with image urls in a char field called ImageURL)
from django.db import models
import requests
import io
class myModel(models.Model)
ImageURL = models.CharField(max_length=250, null=True, blank=True)
@property
def product_image(self):
"Returns the product image"
response = requests.get(self.ImageURL)
image_bytes = io.BytesIO(response.content)
return image_bytes
You can use this property in the inlineimage class of docxtpl and it works
๐คSander
Source:stackexchange.com