serialize field name instead of "pk"

58 views
Skip to first unread message

Brian Craft

unread,
Apr 6, 2012, 9:30:21 PM4/6/12
to django...@googlegroups.com
I have a model with a "name" field that is the primary key. When
serializing, this field gets serialized as "pk" instead of "name".

Is there an easy way to get django to serialize with the actual field
name instead of changing it to pk?

Russell Keith-Magee

unread,
Apr 6, 2012, 11:18:42 PM4/6/12
to django...@googlegroups.com

In short -- no. Django's serializers are fairly primitive, and not especially customizable.

If you need to customize the field names during serialization, you'll either need to roll your own serialization (e.g., write a model->Python dictionary converter, and pass that the json.dumps()), or use a third party serialization tool.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages