#27157: AdminForm may crash if model_admin argument is None
-------------------------------+------------------------------------
Reporter: tpazderka | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Sanghyuk Jeong):
I'd like to work on this ticket.
As Tim suggested in comment:3, I'm taking the deprecation path approach
rather than simply adding None guards.
**Changes:**
- `AdminForm.__init__` and `AdminReadonlyField.__init__` now emit
`RemovedInDjango70Warning` when `model_admin=None`, with a fallback to
`AdminSite.empty_value_display` (default `"-"`) so existing code doesn't
crash immediately.
- `AdminReadonlyField.get_admin_url` gracefully handles `model_admin=None`
by passing `current_app=None` to `reverse()`.
- Fixed `django/contrib/auth/admin.py` (the change password form) to pass
`model_admin=self` instead of relying on the `None` default, as noted in
comment:4 by Shawn Zivontsis.
This sets up a clean path toward making `model_admin` a required argument
in Django 7.0.
PR: https://github.com/django/django/pull/20689
--
Ticket URL: <https://code.djangoproject.com/ticket/27157#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019c55e65b9f-1e81ccb0-7719-43a6-bf61-05a9d7d831ae-000000%40eu-central-1.amazonses.com.