On Mon, 2006-07-17 at 09:41 -0700, Patrick J. Anderson wrote: > Sorry, but would you be able to explain this in detail? I was thinking > about acomplishing this in model classes, not in views, so I'm not sure > if I understand what you mean.
You have to pass the information through from a view, though, because the models have no concept of "logged in user" or "current user" or anything like that: those are view-level concepts. There is no way for a model, on its own, to be able to work out which "user" (whatever that may mean) is performing the action. There are many ways to access models and views are only one way. Still, just to prove that nothing is impossible if you're prepared to be sufficiently devious: if you were really, really determined to do this, you could hook into the pre-save signal on a model, walk back up the Python calling stack to the view function (use the tracback module. You would need a list somewhere detailing what are the view functions so that you knew when had arrived) and then extract the request object from the function's locals and look for the user that way. However, if you use that method, you are not allowed to ever mention my name as having suggested it. I am evil, but I don't want people to know that. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---