Skip to content

Commit

Permalink
Merge pull request sshwsfc#329 from alexsilva/master
Browse files Browse the repository at this point in the history
Django1.9+
  • Loading branch information
sshwsfc authored Jul 25, 2016
2 parents a12f04c + ac6aee6 commit 1ae3d76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xadmin/plugins/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def post(self, request):
else:
return self.get_response()

site.register_view(r'^auth/user/(.+)/update/password/$',
site.register_view(r'^auth/user/(.+)/password/$',
ChangePasswordView, name='user_change_password')
site.register_view(r'^account/password/$', ChangeAccountPasswordView,
name='account_password')
11 changes: 9 additions & 2 deletions xadmin/plugins/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from crispy_forms.utils import TEMPLATE_PACK

from xadmin.layout import FormHelper, Layout, flatatt, Container, Column, Field, Fieldset
from xadmin.plugins.utils import get_context_dict
from xadmin.sites import site
from xadmin.views import BaseAdminPlugin, ModelFormAdminView, DetailAdminView, filter_hook

Expand Down Expand Up @@ -333,8 +334,14 @@ def __init__(self, formset, allow_blank=False, **kwargs):
self.extra_attrs = formset.style.get_attrs()

def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
return render_to_string(
self.template, dict({'formset': self, 'prefix': self.formset.prefix, 'inline_style': self.inline_style}, **self.extra_attrs))
context = get_context_dict(context)
context.update(dict(
formset=self,
prefix=self.formset.prefix,
inline_style=self.inline_style,
**self.extra_attrs
))
return render_to_string(self.template, context)


class Inline(Fieldset):
Expand Down
6 changes: 6 additions & 0 deletions xadmin/plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@


def get_context_dict(context):
"""
Contexts in django version 1.9+ must be dictionaries. As xadmin has a legacy with older versions of django,
the function helps the transition by converting the [RequestContext] object to the dictionary when necessary.
:param context: RequestContext
:return: dict
"""
if isinstance(context, RequestContext):
ctx = {}
map(ctx.update, context.dicts)
Expand Down

0 comments on commit 1ae3d76

Please sign in to comment.