Django Admin page models name instead of TABLE object(id)

1.5k views Asked by At

Is there any way to change the way objects are named in Django Admin page. Currently all of the objects are using a TABLE Object(id) as their name:

table in admin page

Can i make it for example a key form the table like a name or smth. And is there any way to add search bar that goes over the names of the items in the table to filter it by that name.

1

There are 1 answers

1
Onur Taç On

Try this inside your model:

def __str__(self):
    return self.name # this 'name' field must be exist in your model.

For search bar and other things you should read django documentation below:

https://docs.djangoproject.com/en/3.1/ref/contrib/admin/