Commit 0d2b5992 authored by Florent Chehab's avatar Florent Chehab
Browse files

Tweak to force the presence of an id field in server data

parent 05513735
......@@ -33,6 +33,10 @@ class MyModelSerializer(MySerializerWithJSON):
pending_moderation = serializers.SerializerMethodField()
model_config = serializers.SerializerMethodField()
# For easier handling on the client side, we force an id field
# this is usefull when a model has a dedicated primary key
id = serializers.SerializerMethodField()
def get_model_config(self, obj=None):
return self.Meta.model.model_config
......@@ -41,6 +45,9 @@ class MyModelSerializer(MySerializerWithJSON):
return PendingModerationSerializer(obj.pending_moderation, many=True, read_only=True, context=self.context).data
return None
def get_id(self, obj):
class Meta:
model = MyModel
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment