我是tastypie的新手,我正试图发布到以下模型:
class UserScore(models.Model):
"""
User Scores, used to categorise users
"""
user = models.OneToOneField(User)
category = models.ForeignKey(Category)
score = models.IntegerField()
这是我的api:
class UserScoreResource(ModelResource):
category = fields.ForeignKey(CategoryResource, 'category')
user = fields.OneToOneField(UserResource, 'user')
class Meta:
queryset = UserScore.objects.all()
resource_name = 'score'
authorization=Authorization()
allowed_methods = ['post', 'put', 'get']
在我的单元测试中,我正在尝试运行以下内容:
def test_no_post_to_userscore(self):
post_data = {
'user': {'resource_uri':'/api/v1/user/0/'},
'category': {'resource_uri':'/api/v1/category/0/'},
'score': 50,
}
print response.status_code
但是我收到了500错误。任何帮助非常感谢!
答案 0 :(得分:0)
解决了 - 语法错误。漫长的一天
由于