0
models.py當我刪除的模型,我怎樣才能刪除內聯數據和上傳文件
class Issue(models.Model):
issueId = models.AutoField(primary_key=True)
title = models.CharField(max_length = 20)
year = models.IntegerField()
issueDate = models.DateField()
class Preview(models.Model):
issueId = models.ForeignKey(Issue);
previewPath = models.FileField(upload_to='./upload/magazine_sample')
admin.py
class PreviewInline(object):
model = Preview
extra = 1
style = 'accordion'
max_num = 1
class IssueAdmin(object):
list_display = ('title',)
inlines = [PreviewInline]
admin.site.register(Issue, IssueAdmin)
如何刪除預覽和上傳文件當我刪除問題模型?任何人都可以幫助我嗎?
問題和預覽都刪除了,我要刪除上傳文件 –
要刪除圖像,您可能需要使用post_delete信號 –
我是django世界的新手。如何使用post_delete信號? –