Skip to content

Commit

Permalink
Changed attribute in model.Meta to fetch model icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdlin committed Jun 9, 2019
1 parent 2fa985d commit d63c784
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion admin_toolbox/builders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ def __init__(self, model_path, name=None, icon=None, *args, **kwargs):
if self.admin is None:
return
opts = model._meta
meta = getattr(model, 'Meta', None)

try:
self.url = reverse('admin:{opts.app_label}_{opts.model_name}_changelist'.format(opts=opts))
except NoReverseMatch:
return

self.name = name or opts.verbose_name_plural.capitalize()
self.icon = icon or getattr(getattr(model, 'Meta', None), 'menu_icon', None)
self.icon = icon or getattr(meta, '_menu_icon', None) or getattr(meta, 'menu_icon', None)

def build(self, request=None, context=None, menu_name='default'):
if self.url is None:
Expand Down

0 comments on commit d63c784

Please sign in to comment.