그래서 Django 용 TastyPie 플러그인을 사용하여 프로젝트에 REST API를 만들기 시작했습니다. 프로젝트 시작 가이드를 따르고 있었지만, this point에 들어갔을 때 외래 키를 입력해야했을 때 오류가 발생했습니다. 나는 간단한 GET을 수행 할 때외래 키
maior 하나는 이것이다 :
"Reverse for 'api_dispatch_detail' with arguments '()' and keyword arguments '{'pk': 246, 'api_name': 'v1', 'resource_name': 'typep'}' not found."
resources.py의 코드 :
class TypeOfPlaceResource(ModelResource):
class Meta:
queryset = TypeOfPlace.objects.all()
resource_name = 'typep'
allowed_methods = ['get']
class POIResource(ModelResource):
typep = ForeignKey(TypeOfPlaceResource, 'typep')
class Meta:
queryset = PointOfInterest.objects.all()
resource_name = 'pois'
filtering = {
"code1": ALL,
"code2": ALL,
}
그리고 모델 :
class TypeOfPlace (models.Model):
name = models.CharField(max_length=100, blank=True)
code = models.CharField(max_length=20, unique=True)
def __unicode__(self):
return self.name
class PointOfInterest(GeoInformation):
name = models.CharField(max_length=100,blank=True)
code1 = models.CharField(max_length=4,null=True, unique=True)
code2 = models.CharField(max_length=4,null=True, unique=True)
typep = models.ForeignKey(TypeOfPlace)
def __unicode__(self):
return self.name
urls.py
api = Api(api_name='v1')
api.register(TypeOfPlaceResource(), canonical=True)
api.register(POIResource(), canonical=True)
urlpatterns = api.urls
그래서 내가 잘못하고 있니? 아니면 뭔가 빠졌습니까? 어떤 도움이라도 정말 감사 할 것입니다! : D
TastyPie URLconf를 추가 할 수 있습니까? – manji
예! 그냥 주요 질문을 편집] : –
당신이 무슨 URL을 입력 했 습니까이 문제가 발생 했습니까? 'urlpatterns = patterns ('', (r '^ api /', include (api.urls)))로 변경하십시오. – manji