mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 11:11:10 -05:00
Implement historical tracking using django-pghistory; add middleware for context capture and update model architecture
This commit is contained in:
@@ -36,7 +36,23 @@
|
||||
- Use Redis for session storage
|
||||
- Cache invalidation rules
|
||||
|
||||
### Frontend Patterns
|
||||
### Historical Tracking
|
||||
- All model changes create immutable pghistory events
|
||||
- Events contain:
|
||||
- Full object state snapshot
|
||||
- Contextual metadata (user, request fingerprint)
|
||||
- Semantic event label (created, updated, deleted)
|
||||
- Middleware integration:
|
||||
```python
|
||||
# core/middleware.py
|
||||
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')
|
||||
})
|
||||
```
|
||||
|
||||
## Frontend Patterns
|
||||
|
||||
1. HTMX Integration
|
||||
```html
|
||||
|
||||
Reference in New Issue
Block a user