使序列化器具有每个字段的属性

时间:2019-04-19 09:14:30

标签: python json django-rest-framework

我有一个简单的产品模型:

class Product(models.Model):
     title = models.CharField(max_length=120)
     price = models.IntegerField()

如何使用以下属性在Django-Rest-Framework JSON数据中制作:

{

 "title": "Product",
 "price": "100",
 "properties": {
         "title": {
         "description": "The unique name for a product",
         "type": "string"
         },
         "price": {
         "description": "Price of the product",
         "type": "integer"
    }
    },
  "required": [ "productId", "productName" ]
 }

0 个答案:

没有答案