#35729: How to serialize user profiles without natural keys?
--------------------------------------+------------------------------------
Reporter: Jonas Dittrich | Owner: (none)
Type: Bug | Status: closed
Component: Core (Serialization) | Version: dev
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):
* component: contrib.auth => Core (Serialization)
* stage: Unreviewed => Accepted
* type: New feature => Bug
Comment:
After further discussion on the [https://forum.djangoproject.com/t/how-to-
serialize-user-profiles-without-natural-keys/34447 forum], and in a
related ticket (#36225), I agree this is a usability bug in the
serialization framework. The user model aspect is just orthogonal.
Django's pattern of calling `hasattr(obj, "natural_key")` is not subclass-
friendly as pointed out above. There needs to be some way to ''cancel''
natural key serialization in a subclass and check for that. Maybe `def
natural_key() -> tuple[str]` becomes `def natural_key() => tuple[str] |
None`, and `hasattr(obj, "natural_key")` becomes `getattr(obj,
"natural_key", None) is not None`?
--
Ticket URL: <https://code.djangoproject.com/ticket/35729#comment:2>
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/01070199816d7bb1-ce4c4b4c-c7ea-47a8-b4e4-be9718df20cf-000000%40eu-central-1.amazonses.com.