accessing in (passing to) django models signal methods like pre_save, pre_delete the request.user?
Asked Answered
L

1

2

I have to track the history of all of changes, which occure to my models. I also keep track of user making this changes. For now I was dealing with in views.py but I would like to utilitize this functionallity using django signals like pre_save, pre_delete for each of models.

The question are:

1) what is the best way to access there request.user ?

2) What about using Django Admin Logs mentioned here: Storing user activity in Django for accesing user history events?

3) What about the approach of using CurrentUserMiddleware mentioned here: Django: Populate user ID when saving a model

I find the way in 3) very sexy, but does it have some drawbacks?

Literatim answered 14/8, 2014 at 9:55 Comment(0)
B
1

This huge list of packages should do the trick

I personally like the look of:

  • DJANGO REVERSION
  • DJANGO-SIMPLE-HISTORY
  • DJANGO-REVISIONS

because of their rollback functionality.

I can't personally vouch for any of them, not having used them before. Seriously considering changing that though...

Byrnie answered 14/8, 2014 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.