I think signals will be easier, if you also want to record delete
information of a record, you can also hook pre_delete, the pseudo code
is:
from django.db.models import signals
def pre_save(sender, instance, signal, *args, **kwargs):
if instance.id: #update
state = 'change'
old_record = serder.objects.get(id=instance.id) #because the
instance has been changed, so you should get the unchanged record
first
result = #compre old_record and instance
else:
state = 'add'
result = #format instance
WriteLog(state, result)
def pre_delete(sender, instance, signal, *args, **kwargs):
state = 'delete'
result = #format instance
WriteLog(state, result)
dispatcher.connect(pre_save , signal=signals.pre_save)
dispatcher.connect(pre_delete , signal=signals.pre_delete)
--
I like python!
UliPad <<The Python Editor>>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---