简体   繁体   English

Django 在数据库中搜索字段

[英]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.是否可以将我的显示员工更改为搜索块,因为当我 select 时,它会显示一个列表,当我的数据库中有很多数字时,这是不实用的。

add info to an existing employee向现有员工添加信息

You can define __str__()method for your Employee model, it result would be seen in admin dropdown您可以为您的Employee model 定义__str__()方法,结果将在管理员下拉列表中看到

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.试试 select2 小部件,这对你来说应该绰绰有余了。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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