The value of 'filter_horizontal[0]' must be a many-to-many field. The value of 'raw_id_fields[0]' must be a foreign key or a many-to-many field.

在使用django admin的时候 我们遇到这个错误

<class 'Salesman.admin.UsrMngUserAdmin'>: (admin.E020) The value of 'filter_horizontal[0]' must be a many-to-many field.
The value of 'raw_id_fields[0]' must be a foreign key or a many-to-many field.
raw_id_fields = ('department',)  # department必须是多对多,没有多对多的关系 就会报错
filter_horizontal = ('department',)  # department必须是多对多,没有多对多的关系 就会报错
原文地址:https://www.cnblogs.com/xuchunlin/p/6306064.html