Итак, я начал использовать плагин TastyPie для Django, чтобы создать REST API для моего проекта.Я следовал руководству по началу работы с моим проектом, но когда я вошел в этот момент , когда я должен был поставить внешний ключ, он начал давать мне некоторые ошибки.
Мэйнор это когда я получаю простое:
"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