Skip to content

Commit

Permalink
适配django1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
wgbbiao committed Jun 23, 2017
1 parent 24bfb96 commit 78b7e14
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xadmin/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from xadmin.views.base import CommAdminView, ModelAdminView, filter_hook, csrf_protect_m
from xadmin.views.edit import CreateAdminView
from xadmin.views.list import ListAdminView
from xadmin.util import unquote
from xadmin.util import unquote, DJANGO_11
import copy


Expand All @@ -36,15 +36,18 @@ def __init__(self, widgets, attrs=None):
def render(self, name, value, attrs=None):
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, {'name':name})
if DJANGO_11:
final_attrs = self.build_attrs(attrs, extra_attrs={'name': name})
else:
final_attrs = self.build_attrs(attrs, name=name)
final_attrs['class'] = 'nav nav-pills nav-stacked'
output = [u'<ul%s>' % flatatt(final_attrs)]
options = self.render_options(force_text(value), final_attrs['id'])
if options:
output.append(options)
output.append(u'</ul>')
output.append('<input type="hidden" id="%s_input" name="%s" value="%s"/>' %
(final_attrs['id'], name, force_text(value)))
(final_attrs['id'], name, force_text(value)))
return mark_safe(u'\n'.join(output))

def render_option(self, selected_choice, widget, id):
Expand Down Expand Up @@ -337,7 +340,7 @@ def filte_choices_model(self, model, modeladmin):
def model_admin_url(self, name, *args, **kwargs):
return reverse(
"%s:%s_%s_%s" % (self.admin_site.app_name, self.app_label,
self.model_name, name), args=args, kwargs=kwargs)
self.model_name, name), args=args, kwargs=kwargs)


class PartialBaseWidget(BaseWidget):
Expand Down

0 comments on commit 78b7e14

Please sign in to comment.