Skip to content

Commit

Permalink
Added read-only field id to districts (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeffer authored Nov 23, 2024
1 parent 04b148b commit 8425318
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion personal/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ class Meta:

@ts_interface(context='personal')
class DistrictSerializer(serializers.ModelSerializer):
id = serializers.SerializerMethodField('get_id')

class Meta:
model = District
fields = '__all__'
fields = ['id', 'code', 'name', 'abbreviation', 'county']
read_only_fields = ['id']

def get_id(self, obj):
return obj.code


@ts_interface(context='personal')
Expand Down

0 comments on commit 8425318

Please sign in to comment.