Opened 16 years ago

Closed 13 years ago

#10295 closed New feature (needsinfo)

pk name attribute not provided in <object> tag

Reported by: Kausikram Owned by: nobody
Component: Core (Serialization) Version: 1.0
Severity: Normal Keywords: pk name
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

when django serializes an object it creates an object tag having the primary key value as an attribute pk="value" and then provides the other fields as its children. however it never mentions the name of the primary key anywhere. This turns to be disadvantageous when the primary key is not the default id field but something custom specified in the model.

Support by providing a name attribute for the object tag, similar to that provided for the fields tag would be much appreciated.

Attachments (3)

python.py (3.8 KB ) - added by Kausikram 16 years ago.
python.py file of serializer module
xml_serializer.py (8.6 KB ) - added by Kausikram 16 years ago.
xml_serializer.py from serializer module
10295.patch (1023 bytes ) - added by Aymeric Augustin 13 years ago.

Download all attachments as: .zip

Change History (9)

by Kausikram, 16 years ago

Attachment: python.py added

python.py file of serializer module

by Kausikram, 16 years ago

Attachment: xml_serializer.py added

xml_serializer.py from serializer module

comment:1 by Kausikram, 16 years ago

Has patch: set

Attached two files :

  • python.py (change in line#33)
  • xml_serializer.py(change in line#47)

of the serializers module which will now add an extra attribute name to the object tag when serializing into json,python or xml.

comment:2 by Alex Gaynor, 16 years ago

kausikram: Please provides a diff against the root of the tree, instead of multiple complete files.

comment:3 by Kausikram, 16 years ago

Has patch: unset

comment:4 by Jacob, 16 years ago

Triage Stage: UnreviewedDesign decision needed

comment:5 by Chris Beaven, 14 years ago

Severity: Normal
Type: New feature

by Aymeric Augustin, 13 years ago

Attachment: 10295.patch added

comment:6 by Aymeric Augustin, 13 years ago

Easy pickings: unset
Resolution: needsinfo
Status: newclosed
UI/UX: unset

I just uploaded a patch that reflects the changes, but I still don't understand entirely which problem you're trying to solve. I need more info to determine if this is actually the best solution.

You're saying:

This turns to be disadvantageous when the primary key is not the default id field but something custom specified in the model.

Could you elaborate on "disadvantageous"?

Note: See TracTickets for help on using tickets.
Back to Top