One of the ancestors of BlogPost, via Displayable, is TimeStamped (
https://bitbucket.org/stephenmcd/mezzanine/src/6e18580343fa5f4b9221349e11a099a28510bed8/mezzanine/core/models.py?at=default#cl-172)
which covers created on and modified on.  BlogPost itself records the user
that created it so the only missing functionality would be modified by.  To
get modified on you could use a combination of field injection and possibly
monkey patch the BlogAdmin or just write your own BlogAdmin, unregister the
old one and register your new one.


On Thu, Dec 26, 2013 at 11:47 PM, Moltra <[email protected]> wrote:

> I am trying to figure out what is the best way to have the below
> information for each blog post.
>
> Created_by
> Created_on
> Last_modified_by
> Last_modified_on.
>
>
> Is there a field that already logs who created a blog entry?  Is there a
> field that already logs when a Blog entry was created?
>
> Using PHP, I would use system time for created_on and last_modified_on and
> store it in fields in the database.  I would use user.name as the
> created_by and then the Last_modified_by.
>
> I found the below code on stackoverflow.com and it seems like it will
> work, but not sure if there is an easier or more efficient way in
> mezzanine.  This code does not contain the created_on or the
> last_modified_on but would be easy to add them to the code.
>
> def save_model(self, request, obj, form, change):
>  if hasattr(obj, 'created_by') and hasattr(obj, 'modified_by'):
>  if not change:
>  obj.created_by = request.user obj
> obj.modified_by = request.user
>  else:
>  obj.modified_by = request.user
>     obj.save()
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Mezzanine Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to