2013-02-19 55 views
0

我在讀這Django管理formfield爲多對多不工作

https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany

,我試圖用like field查詢dtabase,但我得到的錯誤

FieldError: Join on field 'car' not permitted. Did you misspell 'like' for the lookup type?

我是uisng是代碼

def formfield_for_manytomany(self, db_field, request, **kwargs): 
     if db_field.name == "cars": 
      kwargs["queryset"] = models.Cars.objects.filter(car_like="ford") 
     return super(MyAdmin, self).formfield_for_manytomany(db_field, request, **kwargs) 

回答