Merge pull request #445 from safaariman/master
Performance improvement on parentadminfix_request_path_info^2
commit
378e30cf83
|
|
@ -134,13 +134,14 @@ class PolymorphicParentModelAdmin(admin.ModelAdmin):
|
|||
"""
|
||||
self._lazy_setup()
|
||||
choices = []
|
||||
for model in self.get_child_models():
|
||||
content_types = ContentType.objects.get_for_models(*self.get_child_models(), for_concrete_models=False)
|
||||
|
||||
for model, ct in content_types.items():
|
||||
perm_function_name = "has_{0}_permission".format(action)
|
||||
model_admin = self._get_real_admin_by_model(model)
|
||||
perm_function = getattr(model_admin, perm_function_name)
|
||||
if not perm_function(request):
|
||||
continue
|
||||
ct = ContentType.objects.get_for_model(model, for_concrete_model=False)
|
||||
choices.append((ct.id, model._meta.verbose_name))
|
||||
return choices
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue