Refactor comments app to use mixins for comment functionality; update admin interfaces and add historical model fixes

This commit is contained in:
pacnpal
2025-02-08 16:33:55 -05:00
parent 75f5b07129
commit 03f9df4bab
21 changed files with 548 additions and 280 deletions

View File

@@ -0,0 +1,33 @@
# Historical Model Comment Fixes
## Problem
System check errors occurred because historical models referenced CommentThread in their own app context (e.g. `companies.commentthread`) instead of the actual `comments.CommentThread` model.
## Solution
Added `excluded_fields = ['comments']` to Meta classes of all affected models to exclude comment relationships from historical tracking. Note: Initially tried `history_exclude` but this was incorrect - django-simple-history uses `excluded_fields`.
## Affected Models (Fixed)
- Company (companies/models.py)
- Manufacturer (companies/models.py)
- Designer (companies/models.py)
- Park (parks/models.py)
- ParkArea (parks/models.py)
- Ride (rides/models.py)
- RideModel (rides/models.py)
- Review (reviews/models.py)
## Implementation Details
Each model's Meta class was updated to exclude the comments field from historical tracking:
```python
class Meta:
# ... other Meta options ...
excluded_fields = ['comments'] # Exclude from historical tracking
```
This prevents django-simple-history from attempting to track the GenericRelation field in historical models, which was causing the system check errors.
## Verification
Run system checks to verify fix:
```bash
python manage.py check