Django model method: how to refer to itself?
class A(models.Model):
name = models.CharField(max_length开发者_运维百科=255)
def gen(self):
return AnotherClass(self) # Here I want to pass the class A instance
Is this the write way to do ?
The first named argument in a normal method is passed the instance the method was called on. So, yes.
精彩评论