I have two tables : customers and attributes.They are related as customers.id=attributes.id (for a given id joining the info of customers and attributes one can get the whole profile of the customer).In the Django admin panel of attributes, I want fields from both tables to be shown,search on any开发者_开发知识库 field that i wish and to be able to freely sort on any field.I have provided this foreign key relation in my models.py:
id=models.ForeignKey(customers)
I am able to display any columns that i wish from both the tables (using list_display),and also search on fields from the foreign table.However, the ability to click the title and sort on any column works only on the native fields,not the fields generated from the foreign table.
I also want to show a sum() result of a particular column at the top of the admin interface,like the search bar.
Is this possible in django?
did you try this one?
attributes = Attributes.objects.fi.select_related("event_def", "location", "space")
精彩评论