在我的應用程序中,我想跟蹤所有被刪除的問題。所以我在模型文件中創建了類(表)。在Django中使用Pre_delete信號
class Deleted(models.Model):
question = models.IntegerField(null=True, blank=True)#id of question being deleted
user = models.IntegerField(null=True, blank=True)#id of user deleting the question
dt = models.DateTimeField(null=True, blank=True)#time question is deleted
當用戶試圖刪除問題該刪除功能被稱爲:
def delete_questions(request, user, questions):
for q in questions:
q.delete()
我懷疑是我怎樣才能讓Django的填充我創建了新表的pre_delete信號。
〜新手試圖沉重的任務〜 感謝提前:)
你究竟在遇到什麼麻煩?你讀過有關信號的文件嗎? https://docs.djangoproject.com/en/dev/topics/signals/ –