2014-10-17 17 views

回答

0

可以有兩種不同的解決方案......在Django

1.使用信號來跟蹤每一個CRUD操作,使他們的實例爲每個 signal.Something這樣創建不同的模式...

signals.py 
@receiver(post_save, sender= Sender_model) 
def crud_log(sender,created,**kwargs): 
    obj= kwargs.get('instance') 
    recipient=User.objects.get() 
      Notification.objects.create(
       recipient= recipient, 
       comment= obj, 
       send_by=obj.supporter, 
       text= "%s has commented on %s" % (obj.supporter,obj.project) 
      ) 
      return None 

此處通知是由您製作的模型,用於記錄更改。

2.另一種解決方案是使用django-simple-history