On Fri, Aug 20, 2010 at 4:54 PM, ringemup <ringe...@gmail.com> wrote:
> The admin search isn't searching the ModelAdmin or Inline files, it's > searching the fields from the model. > > You can search a ForeignKey's fields by listing > 'foreignkeyfieldname__relatedmodelfieldname' in your search_fields. > So for example if you had the following models: > > class Author(models.Model): > ... > lastname = models.CharField(max_length=50) > > > class Book(models.Model): > ... > title = models.CharField(max_length=50) > author = models.ForeignKey(Author, related_name='works') > > > Then you could do the following in your admin: > > class BookAdmin(admin.ModelAdmin): > model = Book > search_fields = ['title', 'author__lastname', ...] > > > > However, I'm not sure you can do the reverse: > > class AuthorAdmin(admin.ModelAdmin): > model = Author > search_fields = ['lastname', 'works__title'] > Yes, you can. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.