So I have the following model.
class StoreSegments01(models.Model):
segment = models.FileField(upload_to=content_file_name)
segmentID = models.TextField(max_length=100, default=11)
class StoreSegments01Form(forms.ModelForm):
class Meta:
model = StoreSegments01
fields = ['segment', 'segmentID']
def content_file_name(instance, filename):
return '{0}'.format(instance.segmentID)
I want to provide a way for the users to delete their files. In manage.py shell I try the following:
obj = StoreSegments01.objects.get(segmentID='239fd363-562a-41b3-a915-b7a84cc4a172')
>>> obj.delete()
It deletes the record related to the specified segmentID, but the file associated with the ID is still there. I tried the same with queryset, still the file is not deleted.
What am I missing here?