I have two models:
class Product(models.Model):
name = models.CharField(max_length=200)
price = models.DecimalField(default=0, decimal_places=2, max_digits=10)
def __str__(self):
return self.name
class Receipt(models.Model):
purchase_date = models.DateTimeField(auto_now=True, null=False)
shop = models.ForeignKey(Shop, on_delete=models.SET_NULL, null=True)
products = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
def __str__(self):
return super().__str__()
My receipt url looks like this:

And i would like it to show list of all products, instead of a number of them. How to do this?
My viewsets:
class ReceiptViewSet(viewsets.ModelViewSet):
queryset = Receipt.objects.all()
serializer_class = ReceiptSerializer
permission_classes = [AllowAny]
class ProductViewSet(viewsets.ModelViewSet):
queryset = Product.objects.all()
serializer_class = ProductSerializer
permission_classes = [AllowAny]
enter code here
serializers:
class ProductSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Product
fields = ['id', 'name', 'price']
class ReceiptSerializer(serializers.HyperlinkedModelSerializer):
products = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = Receipt
fields = ['id', 'purchase_date', 'shop', 'products']