views:

73

answers:

1

Howdy!

In the django admin you can set the search_fields for the ModelAdmin to be able to search over the properties given there. My model class has a property that is not a real model property, means it is not within the database table. The property relates to another database table that is not tied to the current model through relations. But I want to be able to search over it, so I have to somehow customize the query the admin site creates to do the filtering when the search field was filled - is this possible and if, how? I can query the database table of my custom property and it then returns the ids of the model classes fitting the search. This then, as I said, has to flow into the admin site search query.

Thanks!

A: 

this might can help

search_fields = ['foreign_key__related_fieldname']

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fields

Tumbleweed
Well, as I said, the model class is not tied to the other model so there is no foreign key. Therefore this does not work.
dArignac
then what is the relation ?
Tumbleweed