#13252: Use the natural key instead of the primary key when serializing ------------------------------------+--------------------------------------- Reporter: SmileyChris | Owner: nobody Status: new | Milestone: Component: Serialization | Version: SVN Resolution: | Keywords: Stage: Accepted | Has_patch: 1 Needs_docs: 1 | Needs_tests: 1 Needs_better_patch: 1 | ------------------------------------+--------------------------------------- Changes (by russellm):
* needs_better_patch: 0 => 1 * stage: Unreviewed => Accepted Comment: I accept the use case - that you should be able to say "update the existing object that matches the natural key, or create a new object if one doesn't exist". However I'm not convinced that providing a natural key for the PK value is the right way to do this. Essentially, this approach means specifying the natural key data twice - once in the fields of the object, and once in the primary key value. This strikes me as especially un-DRY. I haven't given this a lot of thought, but there might be a way of using the natural key without to specify it in the pk attribute. A natural key needs to be unique, so if a model defines a natural key, you shouldn't need to have the PK value specifically (or the natural key value as the primary key) in order to reconstruct the natural key for an object. This does leave the question of when the 'update or create' behavior should be invoked, but I think this will be less prone to error than reproducing the natural key. -- Ticket URL: <http://code.djangoproject.com/ticket/13252#comment:2> Django <http://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 post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.