0
class MyClass(models.Model):
    CONSTANT = "value"
    ...
    class Meta:
        # I want to Access CONSTANT here

I know a simple solution of hardcoding the "value" inside class Meta, but is there a way to access the outer class CONSTANT. I tried CONSTANT and MyClass.CONSTANT inside class Meta, but these two ways did not work.

1 Answers1

0
class MyClass:
    CONST = 'val from MyClass'
    
    def __init__(self):
        self.meta = self.Meta()
    
    class Meta:
        def __init__(self):
            self.value = MyClass.CONST
        
if __name__ == '__main__':
    my_class = MyClass()
    print(my_class.meta.value)


# something like this