class Job_type(models.model):
created_by = UserForeignKey(auto_user_add=True, verbose_name="The user
that is automatically assigned", related_name="Job_type_created_by")
以及www.example.com网站上admin.py
@admin.register(Job_type)
class Job_type_Admin(admin.ModelAdmin):
list_display = ('id','job_type','is_deleted','is_active','created_by',
'created_on','last_modified_by','last_modified_on')
list_display_links = ['id','job_type','created_by']
list_filter = ('job_type','created_by')
search_fields= ('id','job_type','created_by','created_on','last_modified_by','last_modified_on')
list_per_page = 20
请帮助我,我想在搜索字段中创建,但它抛出错误,因为相关字段得到无效的查找- icontain
1条答案
按热度按时间kzmpq1sx1#
该问题是由于:
解决这个问题的一种方法是指定在用户(“created_by”)的哪些字段上启用搜索,即在search_fields列表中尝试用“created_by__username”替换“created_by”。