【问题标题】:"error_message": "'Options' object has no attribute 'module_name'","error_message": "'Options' 对象没有属性 'module_name'",
【发布时间】:2015-06-28 23:55:06
【问题描述】:

我是新 python 所以使用 post 方法 用我的数据

{
"name":"test nassssme123",
"email_id":"test123@gmail.com",
"subject":"test Subject",
"message":"test Message",
"date":"2222222212"
}

那个时候给我错误

{
    "error_message": "'Options' object has no attribute 'module_name'",
    "traceback": "Traceback (most recent call last):\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 201, in wrapper\n    response = callback(request, *args, **kwargs)\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 432, in dispatch_list\n    return self.dispatch('list', request, **kwargs)\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 464, in dispatch\n    response = method(request, **kwargs)\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 1340, in post_list\n    updated_bundle = self.obj_create(bundle, **self.remove_api_resource_names(kwargs))\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 2104, in obj_create\n    return self.save(bundle)\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 2251, in save\n    bundle.objects_saved.add(self.create_identifier(bundle.obj))\n\n  File \"/home/rahul/pyworld/local/lib/python2.7/site-packages/tastypie/resources.py\", line 2232, in create_identifier\n    return u\"%s.%s.%s\" % (obj._meta.app_label, obj._meta.module_name, obj.pk)\n\nAttributeError: 'Options' object has no attribute 'module_name'\n"
}

get 方法对我来说很好用

我的包裹是

defusedxml==0.4.1
Django==1.8
django-extensions==1.5.2
django-tastypie==0.12.1
ipython==3.1.0
MySQL-python==1.2.5
python-dateutil==2.4.2
python-mimeparse==0.1.4
six==1.9.0

【问题讨论】:

  • 我不明白这一点
  • 好的,抱歉,从标签上我猜这是对tastypie 提供的API 端点的发布请求?您如何测试POST 请求,您是否有提交的表单或可能使用其他工具? (类似于curlpostman 等)

标签: python django python-2.7 tastypie


【解决方案1】:

这都是关于版本 Django 1.8 和 Tastypie 现在不能正常协同工作的问题。至少不能像我们之前用 pip 那样安装。 如果您想让它们正常工作,请以这种方式安装支持 Django 1.8 的合并的 sweetpie 代码:

pip install -e https://github.com/django-tastypie/django-tastypie#egg=TastyPie

并更新您的 requirements.txt。删除 django-tastypie==0.12.1 并运行:

pip freeze> requirements.txt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-16
    • 2021-05-28
    • 2013-05-09
    • 2023-01-12
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 2021-08-03
    相关资源
    最近更新 更多