Variable jQuery path for Django version 1.9 and above

master
Daniel Otero 2015-12-08 22:04:05 +01:00
parent f5c08f4116
commit 11e445d99e
2 changed files with 6 additions and 2 deletions

6
adminsortable/admin.py 100644 → 100755
View File

@ -108,6 +108,9 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
has_perm = request.user.has_perm('{0}.{1}'.format(opts.app_label, has_perm = request.user.has_perm('{0}.{1}'.format(opts.app_label,
opts.get_change_permission())) opts.get_change_permission()))
jquery_lib_path = 'admin/js/jquery.js' if VERSION < (1, 9) \
else 'admin/js/vendor/jquery/jquery.js'
# get sort group index from querystring if present # get sort group index from querystring if present
sort_filter_index = request.GET.get('sort_filter') sort_filter_index = request.GET.get('sort_filter')
@ -182,7 +185,8 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
'group_expression': sortable_by_expression, 'group_expression': sortable_by_expression,
'sortable_by_class': sortable_by_class, 'sortable_by_class': sortable_by_class,
'sortable_by_class_is_sortable': sortable_by_class_is_sortable, 'sortable_by_class_is_sortable': sortable_by_class_is_sortable,
'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
} }
return render(request, self.sortable_change_list_template, context) return render(request, self.sortable_change_list_template, context)

View File

@ -9,7 +9,7 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
<script src="{% static 'admin/js/jquery.js' %}"></script> <script src="{% static jquery_lib_path %}"></script>
<script src="{% static 'admin/js/jquery.init.js' %}"></script> <script src="{% static 'admin/js/jquery.init.js' %}"></script>
<script src="{% static 'adminsortable/js/jquery-ui-django-admin.min.js' %}"></script> <script src="{% static 'adminsortable/js/jquery-ui-django-admin.min.js' %}"></script>
<script src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script> <script src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script>