Having the app list available on every admin view

96 views
Skip to first unread message

Riccardo Magliocchetti

unread,
Mar 12, 2015, 1:47:13 PM3/12/15
to django-d...@googlegroups.com
Hello,

i was thinking on export the app_list on every view in the admin to implement a
left menu like the one in mezzanine (demo /demo):
http://mezzanine.jupo.org/it/admin/shop/productoption/

I've started looking in django.contrib.admin.sites and found a couple of issues,
first at line 469, if app_label == model._meta.app_label is true,
shouldn't we add a break after we found an app_label? AFAIU with the django 1.7
app registry rework the label is unique between applications we don't need to do
more work once we have found one

Then there's obviously some duplication between index and app_index methods,
would it make sense to add an helper method with an optional parameter to filter
for the app_label?

Finally it looks to me that everything in the app_dict but the permissions could
be cached somehow. Would it make sense to cache the app_dict so it would be
cheaper to add the app_list in the other views?

thanks in advance

--
Riccardo Magliocchetti
@rmistaken

http://menodizero.it

Aymeric Augustin

unread,
Mar 12, 2015, 4:42:00 PM3/12/15
to django-d...@googlegroups.com
2015-03-12 18:47 GMT+01:00 Riccardo Magliocchetti <riccardo.ma...@gmail.com>:
I've started looking in django.contrib.admin.sites and found a couple of issues, first at line 469, if app_label == model._meta.app_label is true,
shouldn't we add a break after we found an app_label? AFAIU with the django 1.7 app registry rework the label is unique between applications we don't need to do more work once we have found one

Yes, that's correct.
 
Then there's obviously some duplication between index and app_index methods, would it make sense to add an helper method with an optional parameter to filter for the app_label?

Yes, it would. 

Finally it looks to me that everything in the app_dict but the permissions could be cached somehow. Would it make sense to cache the app_dict so it would be cheaper to add the app_list in the other views?

Yes, it looks like there's room for optimization.

PR please? ;-)

--
Aymeric.

Riccardo Magliocchetti

unread,
Mar 13, 2015, 6:10:35 PM3/13/15
to django-d...@googlegroups.com
Il 12/03/2015 21:41, Aymeric Augustin ha scritto:
> 2015-03-12 18:47 GMT+01:00 Riccardo Magliocchetti
> <riccardo.ma...@gmail.com <mailto:riccardo.ma...@gmail.com>>:
> Finally it looks to me that everything in the app_dict but the permissions
> could be cached somehow. Would it make sense to cache the app_dict so it
> would be cheaper to add the app_list in the other views?
>
>
> Yes, it looks like there's room for optimization.
>
> PR please? ;-)

I've taken at stab at it, but test_overriding_has_module_permission test fail.
Looks like the deepcopy of the dict does not work but haven't debugged much.

https://github.com/django/django/compare/master...xrmx:admin_applist?expand=1

I don't like how the code ended up after the second patch though. Need to
measure it is a gain or not.
Reply all
Reply to author
Forward
0 new messages