Allow `null=True` for `LogEntry.user`
- Dominant language
- No language data
- Stars
- 188
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow Django's Code of Conduct
### Feature Description
Add `blank=True, null=True` to the `LogEntry.user` field definition, and change `CASCADE` to `SET_NULL` for it.
Provide more flexibility, and persistence, for tracking admin actions by adding an attribute to `LogEntry` that can contain a text representation of who or what performed the action.
### Problem
1. I have admin actions that can be performed by users as well as by periodically scheduled tasks (think Celery). For the latter case I now have to `get_or_create` a proxy user record for the `LogEntry` for that action. For example:
```python
proxy_user, created = User.objects.get_or_create(
username='DataScrubTask',
defaults={'first_name': 'Proxy user for LogEntry records from "archive_and_scrub_records" task'},
)
```
2. When a user who took an admin action is deleted then the admin history is effectively corrupted. Because of the `CASCADE` for `LogEntry.user`, their actions are deleted from the history.
### Request or proposal
proposal
### Additional Details
This proposal was initially provided in https://code.djangoproject.com/ticket/36555
### Implementation Suggestions
I have created a preliminary, incomplete PR [https://github.com/django/django/pull/19731](https://github.com/django/django/pull/19731) to show my initial thoughts on how to implement this. I will gladly continue work on that if this proposal is accepted.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.