#31472: UserAdmin returns incorrect fieldsets when model has overridden __bool__
-------------------------------------+-------------------------------------
Reporter: krnr | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.auth | Keywords: UserAdmin,
Severity: Normal | add_fieldsets, get_fieldsets
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
in cases when model has "soft-delete" fields and defined `__bool__` like
these:
{{{
class CustomUser(models.User):
is_deleted = models.BooleanField(default=False)
def __bool__(self):
return not self.is_deleted
}}}
the `UserAdmin` will use `add_fieldsets` because of comparison in
`get_fieldsets`.
I have a simple fix for this: just check against `None` instead of boolean
evaluation.
--
Ticket URL: <https://code.djangoproject.com/ticket/31472>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/047.71e5fcffe95ebf49ff9a683a801a1cb8%40djangoproject.com.