Skip to content Skip to sidebar Skip to footer

Automatically Append Host, Port No And Media Folder Path In Url While Retrieve In Django Rest Framework

I'm using Django rest framework APIView method to retrieve image field (Image saved in local and name saved in DB). Is there any way to append Host, Port and media Folder automatic

Solution 1:

You can use build_absolute_uri with ImageFields's url attribute:

url = self.request.build_absolute_uri(val.module_img.url)

Post a Comment for "Automatically Append Host, Port No And Media Folder Path In Url While Retrieve In Django Rest Framework"