[Answered ]-Django Admin panel displays object(like Category Object ) instead of using def __str__(self) function

1👍

The indentation of __str__ is wrong, it is a member of the Category class, so:

class Category(models.Model):
    # …
    
    #   ↓     ↓ member of the Category class
    def __str__(self):
        return self.title

Leave a comment