In my project I encountered the following error.
In my view I copies files from one model to another. However, it seems that some files do not have a counterpart and verification shows that they path exist FileNotFoundError at /home/
. It seems the path exists but the file on the server does not. How to check if file exists before saving to a new model.
My code:
if product.img_1:
obj_apartment.basic_img = product.img_1
I need something like this:
if product.img_1.open():
obj_apartment.basic_img = product.img_1