i am getting this error when i try to  search in admin panel

FieldError at /admin/school/center/
Unsupported lookup 'icontains' for ForeignKey or join on the field not
permitted.

admin.py
@admin.register(Center)
class CenterAdmin(ImportExportModelAdmin, admin.ModelAdmin):
    list_display = ('id', 'state', 'district', 'taluka', 'center',)
    list_filter = ('state', 'district', 'taluka','center')
    search_fields = ('state','district', 'taluka','center',)

model.py
class Center (models.Model):

       state = models.ForeignKey(State, on_delete=models.CASCADE)
       district = ChainedForeignKey(District,
                              chained_field='state',
                              chained_model_field='state',show_all=False,
 auto_choose=True,  sort=True)
       taluka = ChainedForeignKey(Taluka,
                              chained_field='district',

chained_model_field='district',show_all=False, auto_choose=True,  sort=True)


       center = models.CharField(max_length=200)

       def str(self):
            return self.center

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHMymCAkUmAc%3DGiG2mxmfNJLbT%3DYY7XwtCqsdE5m4M_Lr-hfVA%40mail.gmail.com.

Reply via email to