Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---- Model method
- def get_name_request(self):
- """Получение название ресурса"""
- return self.resource_definition().name
- def get_comment_resource(self):
- """Получение комментария ресурса"""
- return self.resource_definition().comment
- def get_resource(self):
- """Возвращает содержимое ресурса"""
- if self.access:
- return self.access.url
- if self.property:
- return f'{self.property.declared_value}/{self.property.serial_number}'
- ---- Serializer
- name_request_field = GenericSerializerField(
- model_field_name='get_name_request',
- field_is_method=True,
- model_field_verbose='get_name_request',
- field_verbose_is_method=True,
- )
- comment_resource_field = GenericSerializerField(
- model_field_name='get_comment_resource',
- field_is_method=True,
- model_field_verbose='get_comment_resource',
- field_verbose_is_method=True,
- )
- resource_field = GenericSerializerField(
- model_field_name='get_resource',
- field_is_method=True,
- model_field_verbose='get_resource',
- field_verbose_is_method=True,
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement