On
http://www.djangobook.com/en/2.0/chapter06/
in models.py:
class Book(models.Model):
title = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
publication_date = models.DateField()
def __unicode__(self):
return self.title
In admin.py:
class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'author', 'publisher')
search_fields = ('first_name', 'last_name')
Is it possible to add 'publisher' into search_fields so that in admin
page books showed can be narrow down by a specific publisher? I tried
it but got the following exception:
Django Version: 1.2.1
Exception Type: TypeError
Exception Value:
Related Field has invalid lookup: icontains
Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/
models/fields/related.py in get_prep_lookup, line 139
Is this not doable? or is it a bug? any fix or workaround available?
or I have to get rid of foreign key relation ship to make it
searchable?
Thank you,
Joe