gpt4 book ai didi

python - “选项”对象没有属性 'module_name'

转载 作者:行者123 更新时间:2023-11-28 19:29:29 27 4
gpt4 key购买 nike

Django 1.8a1
Tastypie 0.12.0

我想通过api来修补我的对象

当我尝试 curl api 时:

 
➜ sesame git:(migration) ✗ curl --dump-header -b cookies -v -H "X-CSRFToken: 5HA6yUXRtdf6KsHK6V52GKm1WkGWuvLh" -H "Content-Type: application/json" -X PATCH --data '{"login": "111"}' http://127.0.0.1:8000/api/v1/serviceAccountEmail/50D2CB33-1ED8-4925-B542-9CE26C961C09/

我得到了错误:


* Rebuilt URL to: cookies/
* Hostname was NOT found in DNS cache
* Could not resolve host: cookies
* Closing connection 0
curl: (6) Could not resolve host: cookies
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#1)
> PATCH /api/v1/serviceAccountEmail/50D2CB33-1ED8-4925-B542-9CE26C961C09/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:8000
> Accept: */*
> X-CSRFToken: 5HA6yUXRtdf6KsHK6V52GKm1WkGWuvLh
> Content-Type: application/json
> Content-Length: 16
>
* upload completely sent off: 16 out of 16 bytes
* HTTP 1.0, assume close after body
HTTP/1.0 500 INTERNAL SERVER ERROR
Date: Mon, 23 Feb 2015 21:56:48 GMT
Server: WSGIServer/0.1 Python/2.7.6
X-Frame-Options: SAMEORIGIN
Content-Type: application/json

{"error_message": "'Options' object has no attribute 'module_name'", "traceback": "Traceback (most recent call last):\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 204, in wrapper\n response = callback(request, *args, **kwargs)\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 444, in dispatch_detail\n return self.dispatch('detail', request, **kwargs)\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 467, in dispatch\n response = method(request, **kwargs)\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 1626, in patch_detail\n self.update_in_place(request, bundle, deserialized)\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 1649, in update_in_place\n return self.obj_update(bundle=original_bundle, **kwargs)\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 2167, in obj_update\n return self.save(bundle, skip_errors=skip_errors)\n\n File \"/home/andrey/repos/sesame/tastypie/resou* Closing connection 1
rces.py\", line 2245, in save\n self.authorized_update_detail(self.get_object_list(bundle.request), bundle)\n\n File \"/home/andrey/repos/sesame/tastypie/resources.py\", line 650, in authorized_update_detail\n auth_result = self._meta.authorization.update_detail(object_list, bundle)\n\n File \"/home/andrey/repos/sesame/tastypie/authorization.py\", line 214, in update_detail\n permission = '%s.change_%s' % (klass._meta.app_label, klass._meta.module_name)\n\nAttributeError: 'Options' object has no attribute 'module_name'\n"}%

Google 无法帮助我解决这种情况

最佳答案

您需要更改您的 curl 选项:

根据 docs :

-b, --cookie <name=data>

(HTTP) Pass the data to the HTTP server as a cookie. It is supposedly the data previously received from the server in a "Set-Cookie:" line. The data should be in the format "NAME1=VALUE1; NAME2=VALUE2".

If no '=' symbol is used in the line, it is treated as a filename to use to read previously stored cookie lines from, which should be used in this session if they match. Using this method also activates the "cookie parser" which will make curl record incoming cookies too, which may be handy if you're using this in combination with the -L, --location option. The file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format.

The file specified with -b, --cookie is only used as input. No cookies will be written to the file. To store cookies, use the -c, --cookie-jar option.

If this option is used several times, the last one will be used.

关于python - “选项”对象没有属性 'module_name',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28684657/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com