-1

我是新来的美味派,正在尝试发布到以下模型:

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 错误。非常感谢任何帮助!

4

1 回答 1

0

已解决 - 语法错误。漫长的一天

谢谢

于 2012-12-19T17:02:55.127 回答