Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 614d11b

Browse files
authored
[templates] Made node template reusable (#51)
1 parent 7ea174a commit 614d11b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

django_netjsongraph/base/admin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@ class AbstractNodeAdmin(BaseAdmin):
144144
def change_view(self, request, object_id, form_url='', extra_context=None):
145145
extra_context = extra_context or {}
146146
link_model = self.model.source_link_set.field.model
147+
admin_url = 'admin:{0}_link_change'.format(self.opts.app_label)
147148
extra_context.update({
148149
'node_links': link_model.objects.select_related('source', 'target')
149150
.only('source__label',
150151
'target__label',
151152
'cost',
152153
'status')
153154
.filter(Q(source_id=object_id) |
154-
Q(target_id=object_id))
155+
Q(target_id=object_id)),
156+
'admin_url': admin_url
155157
})
156158
return super(AbstractNodeAdmin, self).change_view(request, object_id, form_url, extra_context)
157159

django_netjsongraph/templates/admin/django_netjsongraph/node/change_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h2>{% trans 'Links to other nodes' %}: {{ node_links|length }}</h2>
88
<div class="form-row link">
99
<div>
1010
<p>
11-
<a href="{% url 'admin:django_netjsongraph_link_change' link.pk %}">
11+
<a href="{% url admin_url link.pk %}">
1212
{% if link.source_id|lower == object_id|lower %}
1313
{{ link.target }}
1414
{% else %}

0 commit comments

Comments
 (0)