Skip to content

Commit

Permalink
include provider data in offer
Browse files Browse the repository at this point in the history
  • Loading branch information
jbc25 committed May 24, 2024
1 parent a4522fc commit 14757a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/serializers/offers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from rest_framework import serializers

from api.serializers.provider_simple import ProviderSimpleSerializer
from offers.models import Offer


class OffersSerializer(serializers.ModelSerializer):
banner_image = serializers.StringRelatedField(source="banner_image.name")
provider = ProviderSimpleSerializer(many=False, read_only=True)

class Meta:
model = Offer
Expand Down
11 changes: 11 additions & 0 deletions api/serializers/provider_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rest_framework import serializers

from market.models import Provider


class ProviderSimpleSerializer(serializers.ModelSerializer):
profile_image = serializers.StringRelatedField(source="profile_image.name")

class Meta:
model = Provider
fields = ['name', 'profile_image', 'webpage_link']

0 comments on commit 14757a5

Please sign in to comment.