简体   繁体   English

Django无法设置内置/扩展类型'object'的属性

[英]Django can't set attributes of built-in/extension type 'object'

Can anyone see the issues with this? 谁能看到与此有关的问题?

def is_valid(self, bundle, request=None):

    errors = {}
    # Check if user already exists before allowing API to create a new one.
    this_email = bundle.data.get('email', None)
    object.count = MemberParticipant.objects.filter(email=this_email).count()
    if object.count != 0:
         errors['Login']='Duplicate email address! A  participant with the ' \
                         'email address %s already exists.' % this_email
    return errors

I'm getting the following error: 我收到以下错误:

can't set attributes of built-in/extension type 'object' 无法设置内置/扩展类型“对象”的属性

I'm using a Tastypie's custom validator 我正在使用Tastypie的自定义验证器

Are you trying to use object.count as a single variable name? 您是否正在尝试将object.count用作单个变量名? You can't mix dots into identifiers in Python without triggering attribute resolution - use something like object_count instead. 在不触发属性解析的情况下,您无法将点混入标识符中-使用object_count东西代替。 As written you're trying to reassign the count attribute of the built in object class. 如所写,您正在尝试重新分配内置object类的count属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python无法设置内置/扩展类型'object'的属性 - python can't set attributes of built-in/extension type 'object' 添加新的python类型:TypeError:无法设置内置/扩展类型的属性 - Adding new python type : TypeError: can't set attributes of built-in/extension type 如何修复 - TypeError:无法设置内置/扩展类型“set”的属性 - How to fix - TypeError: can't set attributes of built-in/extension type 'set' 真的很奇怪……无法设置内置/扩展类型“lxml.etree._Element”的属性 - Really weird… can't set attributes of built-in/extension type 'lxml.etree._Element' Python 内置数据类型怎么可能具有具有相同数据类型的属性? - How is it possible that a Python built-in data type can have attributes that have the same data type? 按名称动态访问内置类型对象 - Dynamically acessing a built-in type object by name Python,单元测试,模拟内置/扩展类型类方法 - Python, unit test, mock built-in/extension type class method 我在哪里可以找到像 set.symmetric_difference 这样的内置类型方法的类型注释? - Where can I find the type annotations for methods of built-in types like set.symmetric_difference? 我可以向内置 Python 类型添加自定义方法/属性吗? - Can I add custom methods/attributes to built-in Python types? 离开内置的runserver后,为什么Django找不到我的管理媒体文件? - Why can't Django find my admin media files once I leave the built-in runserver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM