Hello Patrick J. Anderson!
On Mon, 17 Jul 2006 10:25:25 -0500 you wrote:

> 
> In my model I'd like to keep track of who added/updated a particular
> record.
> 
> class Entry(models.Model):
>      ...
>      time_added = models.DateTimeField(auto_now_add = True, editable
> = False)
>      user_added = models.ForeignKey(User, default = ?, editable =
> False) time_updated = models.DateTimeField(auto_now = True, editable
> = False) user_updated = models.ForeignKey(user, default = ?, editable
> = False)
> 
> How could I add a currently logged in (to admin interface) user id 
> automatically as a value for that field? Is it possible to do that 
> without writing extra class methods? Any helpful suggestions or tips
> are appreciated.

In our project we use such constractions, and we have common manipulator
views:
        [...]
            if obj and obj.createuser:
                new_data['createuser'] = obj.createuser.id
                new_data['modifyuser'] = str(request.user.id)
            else:
                new_data['createuser'] = str(request.user.id)
                new_data['modifyuser'] = str(request.user.id)
        [...]
and fields createuser and modifyuser alwas has data, if create new
object or modify present one.

Hope that helps you.

-- 
÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ!
greg [at] anastasia [dot] ru çÒÉÇÏÒÉÊ.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to