In my table:
My discount type is DECIMAL:
My data in table:
But why when I fetch data in API, there gets string?
I use Django and Django REST framework as the backend.
belong_product: "server"
ctime: "2018-04-11T15:41:15.744959+08:00"
desc: ""
discount: "0.005"
id: 1
is_enable: false
max_count: 5
min_count: 0
name: "one"
uptime: "2018-04-11T15:41:15.745226+08:00"
My ListAPI view:
class DiscountItemByUserOwnCountListAPIView(ListAPIView):
serializer_class = DiscountItemByUserOwnCountSerializer
permission_classes = [IsSuperAdmin]
pagination_class = CommonPagination
def get_queryset(self):
return DiscountItemByUserOwnCount.objects.all()
My model:
class DiscountItemByUserOwnCount(models.Model):
name = models.CharField(max_length=16, help_text="name")
desc = models.CharField(max_length=512, null=True, blank=True, help_text="desc")
min_count = models.IntegerField(help_text="min")
max_count = models.IntegerField(help_text="max")
discount = models.DecimalField(max_digits=4, decimal_places=3, default=0.000, unique=True,
help_text="point")
belong_product = models.CharField(max_length=16, help_text="belongDISCOUNT_PRODUCT_TYPE")
is_enable = models.BooleanField(default=False)
ctime = models.DateTimeField(auto_now_add=True)
uptime = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
def __unicode__(self):
return self.name
class Meta:
ordering = ['min_count', '-id']