On Sep 7, 9:55 am, Ana <[EMAIL PROTECTED]> wrote:
> Hi,
> I'd like to have  "last modified by" and "owner" fields in my
> application. I'd like to set fields value automatically, and I want
> those  fields to be hidden. Is there any way I can do that?

Yes.

Here's one way to do it:

Add those two fields to your model and set editable=False on them so
they don't show in the Admin.

Override your model's save method and set "last modified by" to
current time i.e. datetime.datetime.now(). Also set the owner to the
request user. Here's an article on how to get request.user using a
custom middleware:

http://lukeplant.me.uk/blog.php?id=1107301634



--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to