Skip to content

Commit

Permalink
add support for url name in qbutton: if the string is a name of url, …
Browse files Browse the repository at this point in the history
…use reverse(url) else, use the url
  • Loading branch information
cc-db-p8 committed Apr 30, 2014
1 parent 1b86d15 commit 0ceccb8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xadmin/views/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db import models
from django.db.models.base import ModelBase
from django.forms.forms import DeclarativeFieldsMetaclass
Expand Down Expand Up @@ -390,7 +390,10 @@ def context(self, context):
btn['title'] = model._meta.verbose_name
btn['icon'] = self.dashboard.get_model_icon(model)
else:
btn['url'] = b['url']
try:
btn['url'] = reverse(b['url'])
except NoReverseMatch:
btn['url'] = b['url']

if 'title' in b:
btn['title'] = b['title']
Expand Down

0 comments on commit 0ceccb8

Please sign in to comment.