Skip to content

Commit

Permalink
Add id field copying code
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe committed May 19, 2024
1 parent 3edb793 commit da72fad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion personal/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ class Meta:
@ts_interface(context='personal')
class SchoolSerializer(serializers.ModelSerializer):
verbose_name = serializers.SerializerMethodField('get_verbose_name')
id = serializers.SerializerMethodField('get_id')

class Meta:
model = School
fields = ['code', 'name', 'abbreviation', 'street',
fields = ['id', 'code', 'name', 'abbreviation', 'street',
'city', 'zip_code', 'email', 'district', 'verbose_name']
read_only_fields = ['id', 'verbose_name']

def get_verbose_name(self, obj):
return str(obj)

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


@ts_interface(context='personal')
class SchoolShortSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit da72fad

Please sign in to comment.