0

I'm getting the following error:

TypeError: 'int' object is not callable

response = receiver(signal=self, sender=sender, **named) File "/Users/user/Documents/workspace/LiveWireSMS/sms/models/message.py", line 156, in my_handler instance.charge = instance.length(instance.content)

From this snippet of code:

@receiver(pre_save, sender=Message)
def my_handler(sender, **kwargs):
    instance = kwargs['instance']
    if not instance.charge:
        instance.charge = instance.length(instance.content)

This is the function its calling:

@property
def length(self):
    return len(self.content) / 160 + 1

Could someone explain the error? Thank you.

1 Answer 1

3

You got this error because length returns an int object and you tried to call it.

instance.charge = instance.length # instead of instance.length(instance.content) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.