简体   繁体   中英

Django search field in the database

is it possible to change my display employe to a search block because when I select the numbers it displays a list which is not practical when I have a lot of numbers in my database.

add info to an existing employee

You can define __str__()method for your Employee model, it result would be seen in admin dropdown

class Employee(models.Model):
    first_name = models.CharField(max_length=50)
    ...

    def __str__(self):
        return self.first_name

Try select2 widget, this should be more than enough for you.

https://django-select2.readthedocs.io/en/latest/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM