Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django Tastypie无法使用非id主键发布_Django_Tastypie - Fatal编程技术网

Django Tastypie无法使用非id主键发布

Django Tastypie无法使用非id主键发布,django,tastypie,Django,Tastypie,我正在使用django tastypie公开一个django模型。但是,我在发布到此资源时遇到一些问题。tastypie似乎不喜欢我在“id”字段之外使用另一个字段作为主键 下面是我看到的错误: "error_message": "Reverse for 'api_dispatch_detail' with arguments '()' and keyword arguments '{'pk': u'VMware-42 30 21 91 31 77 1b 8a-75 c1 4f ab 70 d9

我正在使用django tastypie公开一个django模型。但是,我在发布到此资源时遇到一些问题。tastypie似乎不喜欢我在“id”字段之外使用另一个字段作为主键

下面是我看到的错误:

"error_message": "Reverse for 'api_dispatch_detail' with arguments '()' and keyword arguments '{'pk': u'VMware-42 30 21 91 31 77 1b 8a-75 c1 4f ab 70 d9 99 a6', 'api_name': 'v1', 'resource_name': 'system'}' not found.",
我的模型:

class System(models.Model):
    selinux = models.CharField(max_length=255)
    serialnumber = models.CharField(primary_key=True, max_length=255)
    signer = models.CharField(max_length=255)
    tsm_pvu = models.CharField(max_length=255)
我的资源:

class SystemResource(ModelResource):

    class Meta:
            queryset = System.objects.all()
            authentication = ApiKeyAuthentication()
            authorization = DjangoAuthorization()
            resource_name = 'system'

我最近也有类似的问题。结果表明,原因不是主键是非ID字段,而是主键包含非字母数字字符(例如空格)。在你的例子中似乎也是这样


我发现它还没有与trunk合并,为我解决了这个问题。在tastypie 0.9.11中需要修补的行是文件tastypie/resources.py中(方法库的URL)的第283-284行。希望有帮助

我最近也遇到了类似的问题。结果表明,原因不是主键是非ID字段,而是主键包含非字母数字字符(例如空格)。在你的例子中似乎也是这样

我发现它还没有与trunk合并,为我解决了这个问题。在tastypie 0.9.11中需要修补的行是文件tastypie/resources.py中(方法库的URL)的第283-284行。希望有帮助