mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 08:51:09 -05:00
14 lines
513 B
Python
14 lines
513 B
Python
import pghistory
|
|
|
|
def setup_pghistory_context():
|
|
"""
|
|
Set up pghistory context middleware to track request information.
|
|
This function configures what contextual information is stored
|
|
with each history record.
|
|
"""
|
|
pghistory.context(lambda request: {
|
|
'user': str(request.user) if request.user.is_authenticated else None,
|
|
'ip': request.META.get('REMOTE_ADDR'),
|
|
'user_agent': request.META.get('HTTP_USER_AGENT'),
|
|
'session_key': request.session.session_key
|
|
}) |