Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SingleUserSerializer(GenericSerializer):
- social_network = serializers.SerializerMethodField()
- field_verbose = {
- …
- 'social_network' : 'Соц. сети',
- }
- field_groups = [
- {
- 'verbose': 'Персональная информация',
- },
- {
- 'verbose': 'Должностная информация',
- 'style': GenericSerializer.get_group_style(width=3),
- 'fields': […. 'social_network',]
- },
- ]
- class Meta:
- model = User
- depth = 1
- fields = [
- …
- 'social_network',
- …
- ]
- def get_social_network(self, obj) -> dict:
- value = obj.get_social_network()
- verbose = 'Социальные сети'
- ….
- …..
- return self.get_table_field(
- value=value, verbose=verbose, instance=obj,
- field_name='social_network'
- )
Add Comment
Please, Sign In to add comment