Django Admin showing Object - not working with __unicode__ OR __str__
<p>my Django admin panel is showing <code>object</code> instead of <code>self.name</code> of the object.</p>

<p>I went through several similar questions here yet couldn't seem to resolve this issue. <code>__unicode__</code> and <code>__str__</code> bear the same results, both for books and for authors. I've changed those lines and added new authors/books in every change but no change.</p>

<p><strong>MODELS.PY</strong></p>

<pre><code>from django.db import models
from django.contrib.auth.models import User


# Create your models here.

class Author(models.Model):
    name = models.CharField(max_length=100)


def __str__(self):
    return self.name


class Book(models.Model):
    auto_increment_id = models.AutoField(primary_key=True)
    name = models.CharField('Book name', max_length=100)
    author = models.ForeignKey(Author, blank=False, null=False)
    contents = models.TextField('Contents', blank=False, null=False)


def __unicode__(self):
    return self.name
</code></pre>

<blockquote>
  <p>I used both <strong>unicode</strong> &amp; <strong>str</strong> interchangeably, same result.</p>
</blockquote>

<p>Here are the screenshots of the admin panel by menu/action.</p>

<blockquote>
  <p>1st screen</p>
</blockquote>

<p><a href="http://i.stack.imgur.com/V8dx3.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/V8dx3.jpg" alt="1st screen"></a></p>

<blockquote>
  <p>Author List</p>
</blockquote>

<p><a href="http://i.stack.imgur.com/Ln6qZ.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/Ln6qZ.jpg" alt="Author List"></a></p>

<blockquote>
  <p>Single Author</p>
</blockquote>

<p><a href="http://i.stack.imgur.com/mumdo.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/mumdo.jpg" alt="Single Author"></a></p>

<p>Your indentation is incorrect. You need to indent the code to make it a method of your model. It should be:</p>

<pre><code>class Author(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name
</code></pre>

<p>If you are using Python 3, use <a href="https://docs.djangoproject.com/en/1.10/ref/models/instances/#str" rel="nofollow"><code>__str__</code></a>. If you are using Python 2, use <code>__unicode__</code>, or decorate your class with the <code>python_2_unicode_compatible</code> decorator. After changing the code, make sure you restart the server so that code changes take effect.</p>

python django postgresql