How to call a method inside the class model in python django

28°
Deal Newbie
gorgenasty

In models.python

class ModelA(models.Model):

def methodA(self):
return …
methodA() # How to call this methodA, this line is giving error.
How to call methodA from inside the class. I tried self.methodA(), but there is NameError on ‘self’. I also tried ModelA.methodA(), but here comes an error as name ‘ModelA’ is not defined.

Expired
1 Comment  |  
2 Dimers
  • Sort By
Deal Cadet Deal Cadet
Link Copied

post the same on stackoverflow

replyuser
Click here to reply
Reply