wagtail-nest / wagtail-modeladmin

Add any model in your project to the Wagtail admin. Formerly wagtail.contrib.modeladmin.
Other
21 stars 8 forks source link

Optimise the rendering process for ModelAdmin's IndexView #11

Open ababic opened 7 years ago

ababic commented 7 years ago

Currently, when rendering a row of items in IndexView, the following things happen:

  1. In templates/modeladmin/index.html the {% result_list %} tag is called
  2. result_list does some working out, then renders a template templates/modeladmin/includes/result_list.html
  3. The above template cycles through the results created by result_list and calls another tag {% result_row_display %} for each row.
  4. {% result_row_display %} renders another template (templates/modeladmin/result_row.html), which cycles through each of the column values for that row and calls another template tag {% result_row_value_display %} to render each of those (In a listing of 100 items with 5 columns each result_row_value_display would be called 500 times).
  5. result_row_value_display renders a template (templates/modeladmin/result_row_value.html) to show the column value, and also conditionally includes another template (templates/modeladmin/includes/button.html) if buttons need to be included.

I would like to make it so that {% result_row_display %} in step 4 does everything it needs to do, and can just render everything to templates/modeladmin/result_row.html, without having to call upon more tag calls or templates.

I've already managed this once in another branch (https://github.com/rkhleics/wagtail/blob/modeladmin/style-tweaks/wagtail/contrib/modeladmin/templatetags/modeladmin_tags.py), but it was part of a PR that ended up going way out of scope and I cancelled in the end, because it never would have been merged.

Hopefully now, with a clearer brief, I can recreate the changes in their own PR and it'll be possible to review them on their own?