![]() ![]() MacAddresses = serializers.RelatedField(many=True) Mapping = models.ForeignKey('imaging.WindowsMapping', related_name='macAddresses')Ĭlass WindowsCompleteMappingSerializer(serializers.Serializer): MacAddresses = serializers.SlugRelatedField(slug_field='address', many=True, read_only=True)Īlternatively, if the _str_ of the WindowsMacAddress simply displays the address, then you could simply use RelatedField, which is a basic read-only field that will give you a simple string representation of the relationship target. class WindowsCompleteMappingSerializer(serializers.Serializer): You can also use SlugRelatedField, which represents the relationship, using a given field on the target. There's also a couple of other approaches you could take. Carlton's answer will work do the job just fine. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |