Skip to content

Commit

Permalink
Fix relate plugin rel_name mistake bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
sshwsfc committed Nov 22, 2016
1 parent fa52c31 commit 730b5c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xadmin/plugins/relate.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(self, admin_view, lookup, value):
raise Exception(u'Relate Lookup field must a related field')

self.to_model = field.related_model
self.rel_name = field.remote_field.name
self.rel_name = '__'.join(parts[1:])
self.is_m2m = bool(field.many_to_many)

to_qs = self.to_model._default_manager.get_queryset()
Expand Down Expand Up @@ -184,6 +184,8 @@ def url_for_result(self, url, result):
def get_context(self, context):
context['brand_name'] = self.relate_obj.get_brand_name()
context['rel_objs'] = self.relate_obj.to_objs
if len(self.relate_obj.to_objs) == 1:
context['rel_obj'] = self.relate_obj.to_objs[0]
if 'add_url' in context:
context['add_url'] = self._get_url(context['add_url'])
return context
Expand Down

0 comments on commit 730b5c8

Please sign in to comment.