Reputation: 6555
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
Upvotes: 1
Views: 479
Reputation: 37344
Are you trying to use object.count
as a single variable name? You can't mix dots into identifiers in Python without triggering attribute resolution - use something like object_count
instead. As written you're trying to reassign the count attribute of the built in object
class.
Upvotes: 1