Proper context and breadcrumbs

master
Igor Sobolev 2016-11-02 12:47:36 -04:00
parent b96896d890
commit 12fbb62302
2 changed files with 12 additions and 8 deletions

View File

@ -219,11 +219,11 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
except AttributeError: except AttributeError:
verbose_name_plural = opts.verbose_name_plural verbose_name_plural = opts.verbose_name_plural
context = { context = self.admin_site.each_context(request)
context.update({
'title': u'Drag and drop {0} to change display order'.format( 'title': u'Drag and drop {0} to change display order'.format(
capfirst(verbose_name_plural)), capfirst(verbose_name_plural)),
'opts': opts, 'opts': opts,
'app_label': opts.app_label,
'has_perm': True, 'has_perm': True,
'objects': objects, 'objects': objects,
'group_expression': sortable_by_expression, 'group_expression': sortable_by_expression,
@ -232,7 +232,7 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
'sortable_by_class_display_name': sortable_by_class_display_name, 'sortable_by_class_display_name': sortable_by_class_display_name,
'jquery_lib_path': jquery_lib_path, 'jquery_lib_path': jquery_lib_path,
'csrf_cookie_name': getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken') 'csrf_cookie_name': getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken')
} })
return render(request, self.sortable_change_list_template, context) return render(request, self.sortable_change_list_template, context)
def add_view(self, request, form_url='', extra_context=None): def add_view(self, request, form_url='', extra_context=None):

View File

@ -37,12 +37,16 @@
{% if not is_popup %} {% if not is_popup %}
{% block breadcrumbs %} {% block breadcrumbs %}
<div class="breadcrumbs"> <div class="breadcrumbs">
<a href="../../../"> <a href="{% url 'admin:index' %}">
{% trans "Home" %} {% trans "Home" %}
</a> </a>
&rsaquo; &rsaquo;
<a href="../../"> <a href="{% url 'admin:app_list' app_label=opts.app_label %}">
{{ app_label|capfirst }} {{ opts.app_config.verbose_name }}
</a>
&rsaquo;
<a href="{% url opts|admin_urlname:'changelist' %}">
{{ opts.verbose_name_plural|capfirst }}
</a> </a>
&rsaquo; &rsaquo;
{% trans 'Reorder' %} {% trans 'Reorder' %}
@ -72,7 +76,7 @@
{% block object-tools %} {% block object-tools %}
<ul class="object-tools"> <ul class="object-tools">
<li> <li>
<a href="../"> <a href="{% url opts|admin_urlname:'changelist' %}">
{% blocktrans with opts.verbose_name_plural|capfirst as model %}Return to {{ model }}{% endblocktrans %} {% blocktrans with opts.verbose_name_plural|capfirst as model %}Return to {{ model }}{% endblocktrans %}
</a> </a>
</li> </li>