#33931: Optimize calling of `get_app_list` with AdminSites index/app_index
------------------------------------------------+------------------------
               Reporter:  Daniel Hahler         |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  contrib.admin         |        Version:  4.1
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 `AdminSite.index` gets the list of available apps twice: for `app_list`
 and `available_apps` in the context.

 Code ref:
 
https://github.com/django/django/blob/bee09df39fe0734eb2388a2b3439436796592820/django/contrib/admin/sites.py#L547-L555

 I think this can be optimized to only call it once.

 With `app_index` it could also be filtered in `app_index` itself.

 The benefit of this is handling the use case of moving apps around in
 `get_app_list` (from `custom_auth` into `auth`, after calling the default
 method), which fails when the list is filtered by `app_label` before.

 I think changing `index` makes sense, and is the far more often used code
 path, but changing `app_index` might break some projects, where by now it
 might be expected that `get_app_list` gets called with an `app_label` -
 and optimizing it there removed the internal use of calling `get_app_list`
 with `app_label` completely again.  (This was changed in Django 4.1:
 https://code.djangoproject.com/ticket/7497)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33931>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182ab1373ca-9434db9f-5127-4d22-8128-8093e64f0b91-000000%40eu-central-1.amazonses.com.

Reply via email to