Collection (list) view
When querying a page of items in the collection, i.e the “list” view, all fields get loaded, including smart fields, etc.
I’d like this to be customisable as some smart fields we have configured are very resource intensive. Ideally, I’d like to mark a smart field to be loaded in the detail/summary view of a single record.
Hello and welcome,
You can manage your list view with this section of the documentation.
Let me know if it is ok for you
Hey! Thank you for the response. Alas, I’ve already done this – my API still gets hit for the smart field, even though it is not selected to be shown in the list view.
Could you send me the http request sent by the frontend please ? And tell me if you find your smart field inside. You can find it in the “network” section from the web inspector.
Yep, will attach.
The request URL:
The smart field in particular, is not included in that list of fields. I can also confirm that the smart field does also not get returned in the response.
The problem however, is that the smart field’s value is in fact calculated.
Here is some of the Forest Admin Django plugin’s call trace
In here it simply goes:
smart_fields = [x for x in collection['fields'] if x['is_virtual']] which I can imagine is the problem, as it’s not respecting the query. It then calls
handle_get_method for each smart field.
Only on the way out, in
ListView::serialize are the request’s parameters respected, and this is where the hidden smart field is stripped out.
Thus, the problem exists that every query hits every smart field.
Thanks for your PR, I’ll check it soon.