Skip to content

Commit

Permalink
AdminSite detection support for various python/django versions #105
Browse files Browse the repository at this point in the history
  • Loading branch information
darklow committed Dec 27, 2013
1 parent 584c3fc commit dbf19d1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions suit/templatetags/suit_menu.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import template
from django.contrib import admin
from django.contrib.admin import AdminSite
from django.core.handlers.wsgi import WSGIRequest
from django.core.urlresolvers import reverse, resolve
import warnings
Expand Down Expand Up @@ -33,9 +34,10 @@ def get_admin_site(current_app):
in func_closer dict in index() func returned by resolver.
"""
try:
url = reverse('%s:index' % current_app)
resolver_match = resolve(url)
return resolver_match.func.func_closure[1].cell_contents
resolver_match = resolve(reverse('%s:index' % current_app))
for func_closure in resolver_match.func.func_closure:
if isinstance(func_closure.cell_contents, AdminSite):
return func_closure.cell_contents
except:
return admin.site

Expand Down

0 comments on commit dbf19d1

Please sign in to comment.