So I have this piece of code:
class QuerySetUpdateOverriden(QuerySet, object):
def update(self, *args, **kwargs):
super().update(*args, **kwargs)
if hasattr(self, method):
self.method()
return
I want to override the update method and if the second class that it inherits has a specific method, call that too.
But I get an error on the line containing the if statement saying "name method is not defined".
Why is this happening and how can I fix it?
Thanks.
methoddefined? If you're trying to get the nameupdateprogrammatically, this may help.hasattrshould be a string, because you don't pass variables to functions, you pass values.