Commit bd9cdc40 authored by Gladys Forte's avatar Gladys Forte

remove media file

parent 6aeb2829
......@@ -15,6 +15,7 @@ from rest_framework.exceptions import ParseError
from django.db import IntegrityError
from rest_framework.exceptions import APIException
from django.db.models import Max
import os
CR_FRONT_LINK = settings.CR_FRONT_LINK
......@@ -502,7 +503,13 @@ def crhistory_log_bulk_delete_masterattach(queryset, entity, tbl, form_code,
print(r['url'])
print(settings.MEDIA_ROOT)
# os.remove(os.path.join(settings.MEDIA_ROOT, self.url.name))
# os.remove(r['url'])
if os.path.exists(r['url']):
os.remove(r['url'])
else:
print("The file does not exist")
return True
except IntegrityError as exc:
raise APIException(detail=exc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment