[英]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.