Code

Opened 8 years ago

Closed 8 years ago

#2701 closed enhancement (fixed)

[patch] Limit which fields are serialized in serializers.serialize.

Reported by: deryck@… Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

After playing with the serializer stuff, I wanted to be able to limit which fields in the model were serialized. The app I
was playing with had a few fields that I didn't need and didn't really want in publicly viewable JavaScript. This would look something like:

serializers.serialize('json', foo.objects.all(), fields=('somefield', 'anotherfield'))

The patch provides "fields" as an optional parameter. Without it, the serializer works as normal.

Attachments (1)

serialize_limit_by_field.diff (1.3 KB) - added by deryck@… 8 years ago.
Provides fields as an optional paramter to serializers.serialize.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by deryck@…

Provides fields as an optional paramter to serializers.serialize.

comment:1 Changed 8 years ago by deryck@…

  • Summary changed from Limit which fields are serialized in serializers.serialize. to [patch] Limit which fields are serialized in serializers.serialize.

Change summary to reflect patch.

comment:2 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [4042]) Fixed #2701: Added "fields" argument to serializers.serialize. Thanks, Deryck.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.