当我尝试访问http://localhost:8000/api/goal/?format=json时出现以下错误:
ImproperlyConfigured at /api/goal/
The included urlconf <property object at 0x262bb50> doesn't have any patterns in it
以下是我添加到urls.py中的内容:
goal_resource = GoalResource
...
url(r'^api/', include(goal_resource.urls)),
这是我的api.py:
class GoalResource(ModelResource):
class Meta:
queryset = Goal.objects.all()
resource_name = 'goal'
知道可能出现什么问题吗?
答案 0 :(得分:7)
你需要调用GoalResource,而不仅仅是将它的内存地址绑定到变量。所以改变
goal_resource = GoalResource
到
goal_resource = GoalResource()