On Tue, 2009-01-20 at 07:46 -0800, Dan wrote: > Hello, > > I am trying to make an application that can log events (changes to the > database) from other django applications. To do this i am currently > using the post_save hook and post_delete hook to get any inserts, > updates or deletes however i am unable to get the user that caused > them. > > Is there a simple and tested way i can use to get the user from a > request out side of a view?
The problem with your question is that it doesn't necessarily have an answer. Outside of the normal request/response path (when views are called), the concept of a "user" might not exist. Django's modules can be used in cronjobs and even manually run scripts when there's no "user" involved. That's why, if you want access to the user, you need to pass it around. Still, providing your code is also able to handle the case when there's no user object, have a look at http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser and http://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser for some ideas. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---