Unable to sort in more than one application in project - fixed.
parent
22cd63a4ba
commit
1c2964c566
|
|
@ -55,9 +55,9 @@ class SortableAdmin(ModelAdmin):
|
|||
admin_urls = patterns('',
|
||||
url(r'^sorting/do-sorting/(?P<model_type_id>\d+)/$',
|
||||
self.admin_site.admin_view(self.do_sorting_view),
|
||||
name='admin_do_sorting'), #this view changes the order
|
||||
name=('%s_do_sorting' % self.model._meta.app_label)), #this view changes the order
|
||||
url(r'^sort/$', self.admin_site.admin_view(self.sort_view),
|
||||
name='admin_sort'), #this view shows a link to the drag-and-drop view
|
||||
name=('%s_sort' % self.model._meta.app_label)), #this view shows a link to the drag-and-drop view
|
||||
)
|
||||
return admin_urls + urls
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n adminmedia %}
|
||||
{% load i18n adminmedia adminsortable_tags %}
|
||||
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
||||
<h2>{{ inline_admin_formset.opts.verbose_name_plural|title }} {% if inline_admin_formset.opts.is_sortable %} - drag and drop to change order{% endif %}</h2>
|
||||
{{ inline_admin_formset.formset.management_form }}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
{% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
|
||||
{{ inline_admin_form.fk_field.field }}
|
||||
{% if inline_admin_form.original %}
|
||||
<input type="hidden" name="admin_sorting_url" value="{% url admin:admin_do_sorting inline_admin_form.original.model_type_id %}" />
|
||||
<input type="hidden" name="admin_sorting_url" value="{% get_do_sorting_url inline_admin_form.original.model_type_id %}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n adminmedia admin_modify %}
|
||||
{% load i18n adminmedia admin_modify adminsortable_tags %}
|
||||
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
||||
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
|
||||
{{ inline_admin_formset.formset.management_form }}
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
{% if inline_admin_form.original %}
|
||||
<input type="hidden" name="admin_sorting_url" value="{% url admin:admin_do_sorting inline_admin_form.original.model_type_id %}" />
|
||||
<input type="hidden" name="admin_sorting_url" value="{% get_do_sorting_url inline_admin_form.original %}" />
|
||||
{% endif %}
|
||||
</td>
|
||||
{% for fieldset in inline_admin_form %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{% load adminsortable_tags %}
|
||||
|
||||
<form>
|
||||
<input name="pk" type="hidden" value="{{ object.pk }}" />
|
||||
</form>
|
||||
<a href="{% url admin:admin_do_sorting object.model_type_id %}" class="admin_sorting_url">{{ object }}</a>
|
||||
<a href="{% get_do_sorting_url object %}" class="admin_sorting_url">{{ object }}</a>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from django import template
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
|
@ -33,3 +34,7 @@ def render_object_rep(context, obj, sortable_object_rep_template='adminsortable/
|
|||
tmpl = template.loader.get_template(sortable_object_rep_template)
|
||||
return tmpl.render(context)
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=False)
|
||||
def get_do_sorting_url(obj):
|
||||
return reverse('admin:%s_do_sorting' % obj._meta.app_label, kwargs={'model_type_id': obj.model_type_id() })
|
||||
Loading…
Reference in New Issue