The point of the queries is to get information about the underlying Documents in each Collection, and display it in the admin page. For example, title is one attribute, but there are also other that I want to display.
Your idea obj.document.all().values_list('title', flat=True) makes a lot of sense - Thanks!
Now, a bigger question. Say I have two fields in Documents that I want to display side by side in a table in the Collection admin page. I would have two entries in the list_display:
list_display = ('get_field_1', 'get_field_2', )
and two functions, and each one calls obj.document.all(), which returns a query set of Documents in this particular Collection.
def get_field_1(self, obj):
tempstr = ""
documents = obj.document.all()
for d in documents:
tempstr = tempstr + d.field_1
return tempstr
def get_field_2(self, obj):
tempstr = ""
documents = obj.document.all()
for d in documents:
tempstr = tempstr + d.field_2
return tempstr
These two "list of fields" from the Documents are displayed side by side. Will the first entry in the field_1 list always correspond to the first entry in the field_2 list? In other words, I am concerned about the order of the documents returned in the query set obj.document.all(). Will it always be the same?
Perhaps a picture will help (I hope it comes through). Note the ordered lists of file names and thumbnails. I used the code above (with a few modifications) to generate the table. My concern is if the file name in the first list (a field in the Document model) will always correspond to the thumbnail in the second column (another field in the Document model).
Thanks!