0
爲什麼我的api沒有顯示任何pk的租賃模型?我用tastypie來休息api。畫廊模式的標識顯示而不是租賃model.This的是我的API我的API沒有顯示任何pk的租賃模型
class RentalResource(MultipartResource,ModelResource):
gallery = fields.ToManyField('rentals.api.api.GalleryResource', 'gallery', related_name='rental',full=True)
class Meta:
queryset = Rental.objects.all()
resource_name = 'rental'
detail_uri_name = 'slug'
allowed_methods = ['get', 'post', 'put']
fields = ['listingName','id','slug','property','city','place','ownerName','room','water','amenities','price','summary','phoneNumber','email']
filtering = { "property" : ALL , "id":All, "city":ALL, "place":('exact', 'startswith',), "room":ALL,"price":ALL,"listingName":ALL,"slug":ALL}
authorization = DjangoAuthorization()
class GalleryResource(ModelResource):
rental = fields.ForeignKey(RentalResource, 'rental',full=False, null=True, blank=True)
class Meta:
queryset = Gallery.objects.all()
resource_name = 'gallery'
allowed_methods = ['get','post','put']
authorization = DjangoAuthorization()
在django中,pk字段是不是真的叫做'id'? – 2ps
我試過使用ID,但沒有顯示ID,所以我嘗試使用PK。 – milan
請出示您的'Rental'模型定義 –