为什么我的api没有显示任何租赁模式?我用tastypie来休息api。显示画廊模型的ID但不显示租赁模型。这是我的api代码
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()
答案 0 :(得分:0)
因为for key in dict:
if re.match(type + r'(' + mode + r'|\*)', key):
print(dict[key])
中有detail_uri_name = 'slug'
。删除此行。