vvangelovski / django-audit-log

Audit log for your Django models
Other
232 stars 93 forks source link

How to get log_entry.action_date value #18

Closed vaibhav-jain closed 9 years ago

vaibhav-jain commented 9 years ago

I need to access log_entry.action_date value. Right now I can access <Customer: XXXX deleted at 2015-01-17 19:09:48.515000+00:00> But how do I render this string into datetime value in template????? Is their way of getting access to log_entry.action_date??

vvangelovski commented 9 years ago

log_entry.action_date gives you the datetime of the action.

vaibhav-jain commented 9 years ago

Yeah but how do i access it using manager???

vaibhav-jain commented 9 years ago

I need to show action datetime in templates in user specific time format.

vaibhav-jain commented 9 years ago

Can you please tell me that should I use TimeStampedModel from django-extensions along with audit-log

vvangelovski commented 9 years ago

You can use TimeStampedModel from django-extensions on any model if you want to. Don't confuse it with AuthStampedModel from django-audit-log.

To get the datetime of a certain action you need to get an instance of the log entry for that action. You can't get it from the manager.

In the example that you gave log_entry.action_date will give you the datetime for that log_entry, it's not a string it's a datetime.

vaibhav-jain commented 9 years ago

Thanks for your help. It was all my mistake. self.audit_log.filter().order_by('-action_date')[0] . I forgot .action_date in the query self.audit_log.filter().order_by('-action_date')[0].action_date. So sorry