maximum recursion depth exceeded getter Django
<p>I have some class with custom getter for specific attr:</p>

<pre><code>class Item(a, b, c, d, models.Model):
     title = Field()
     description = Field()
     a = Field()
     _custom_getter = ['title','description']

     def __getattribute__(self, name):
         if name in self.custom_getter:
             return 'xxx'
         else:
             return super(Item, self).__getattribute__(name)
</code></pre>

<p>this code raise <code>RunetimeError</code>: <code>maximum recursion depth exceeded while calling a Python object</code>
but when i use this piece of code:</p>

<pre><code>class Item(a, b, c, d, models.Model):
    title = Field()
    description = Field()
    a = Field()

    def __getattribute__(self, name):
        custom_getter = ['title','description']
        if name in custom_getter:
            return 'xxx'
        else:
            return super(Item, self).__getattribute__(name)
</code></pre>

<p>all works like I want. Wher is my mistake in first piece of code ?</p>

<p>Because <code>__getattribute__</code> gets called when you do <code>self.custom_getter</code>. You can use <code>self.__dict__</code> for this. Read more <a href="http://stackoverflow.com/questions/371753/python-using-getattribute-method#371833">Python - Using __getattribute__ method</a></p>

<pre><code>class Item(a, b, c, d, models.Model):
     title = Field()
     description = Field()
     a = Field()
     custom_getter = ['title','description']

     def __getattribute__(self, name):
         if name in self.__dict__['custom_getter']:
             return 'xxx'
         else:
             return super(Item, self).__getattribute__(name)
</code></pre>

python django recursion django-models attributes