Opened 6 years ago

Closed 4 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 6 years ago.
python.py file of serializer module
xml_serializer.py (8.6 KB) - added by kausikram 6 years ago.
xml_serializer.py from serializer module
10295.patch (1023 bytes) - added by aaugustin 4 years ago.

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by kausikram

python.py file of serializer module

Changed 6 years ago by kausikram

xml_serializer.py from serializer module

comment:1 Changed 6 years ago by kausikram

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 6 years ago by Alex

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

comment:3 Changed 6 years ago by kausikram

  • Has patch unset

comment:4 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Design decision needed

comment:5 Changed 4 years ago by SmileyChris

  • Severity set to Normal
  • Type set to New feature

Changed 4 years ago by aaugustin

comment:6 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Resolution set to needsinfo
  • Status changed from new to closed
  • 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