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

22°
Deal Newbie
50
20
0

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 4 months
1 Comment  |  
2 Dimers
  • Sort By
Missing