how to log model inserts,updates and deletes? I am not using django admin,in my app there are multiple tables i just want to records only which model or table name,开发者_如何学JAVA field name,previous value,who edited,and what time to log table?
Who edited (my app uses SSO,it should pick up remote user automatically)
can you please suggest any built in function or module in django to records this kind of logs ,if possible can you plz add few lines of django code or any ref links?
Thanks in advance
You can try this:
from django.db.models.signals import post_save
def logging_function(sender, **kwargs):
# do your logging
post_save.connect(logging_function)
Python has a logger http://docs.python.org/library/logging.html What's wrong with that?
You can, also, add an event table to your Django models and write to that table.
For real fun, you can create a decorator which writes to that table.
You can search, too. You'll find things like this: http://djangosnippets.org/snippets/2111/
精彩评论