#36555 closed New feature (wontfix)
Allow null for LogEntry.user
| Reported by: | Siburg | Owned by: | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Siburg, Carsten Fuchs | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The user attribute of LogEntry is currently required. That causes two problems for me:
- 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_createa proxy user record for theLogEntryfor that action. For example:proxy_user, created = User.objects.get_or_create( username='DataScrubTask', defaults={'first_name': 'Proxy user for LogEntry records from "archive_and_scrub_records" task'}, ) - When a user who took an admin action is deleted then the admin history is effectively corrupted. Because of the
CASCADEforLogEntry.user, their actions are deleted from the history.
To eliminate those problems I propose to add blank=True, null=True to the user field definition, and change CASCADE to SET_NULL.
To provide more flexibility for tracking actions, I also propose to add a CharField that can contain a text representation of who or what performed the action.
I have created a preliminary, incomplete PR https://github.com/django/django/pull/19731 to show my proposed approach. I will gladly continue work on that if this proposal is accepted.
Change History (3)
comment:1 by , 2 months ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
comment:2 by , 2 months ago
| Description: | modified (diff) |
|---|
comment:3 by , 4 weeks ago
| Cc: | added |
|---|
Hi Siburg, thank you for the suggestion!
When suggesting a new feature for Django, the feature idea should first be proposed and discussed with the community. To do that, please raise this on the new feature tracker.
I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.
Thanks!