내가 이런 일을 할 때 http://example.com/api/v1/nisit/?format=json. 이 오류가 발생합니다 "모델 ''빈 특성 '페이지'있고 null 값을 허용하지 않습니다."맛이 역방향 관계를 사용하는 방법
tastypie의 역 관계를 사용하고 싶습니다. "페이지"모델 양식 "nisit"모델과 반대입니다. 내가 원하는 결과가 호출하는 것입니다 127.0.0.1:8000/api/v1/nisit/?format=json & friend_ followingPage _id = 문제의 지점을 설정하는 방법 followingPage 속성을 Nisit에 "1
모델 페이지 모델의 followingNisit 속성에 역의 관계이다
이이 내 자원 내 모델
class Nisit(models.Model):
friends = models.ManyToManyField('self',null=True,blank=True)
class Page(models.Model):
followingNisit = models.ManyToManyField(Nisit,blank=True)
입니다
class NisitResource(ModelResource):
friend = fields.ManyToManyField('self','friend',null=True)
followingPage = fields.ToManyField('chula.api.resourse.PageResource','followingPage')
class Meta:
queryset = Nisit.objects.all()
resource_name = 'nisit'
filtering = {
'friend' : ALL_WITH_RELATIONS,
'id' : ALL,
}
위 코드에서. 나는이 링크 http://django-tastypie.readthedocs.org/en/latest/resources.html#reverse-relationships 에 따라 ................. >>>> 페이지를 = 코드를하려고하지만 추가
class PageResource(ModelResource):
followingNisit = fields.ManyToManyField(NisitResource, 'followingNisit',null=True)
class Meta:
queryset = Page.objects.all()
resource_name = 'page'
authorization= Authorization()
filtering = {
'followingNisit': ALL_WITH_RELATIONS,
'p_name': ALL,
}