Форум сайта python.su
вылазит вот такая вот беда:
Caught AssertionError while rendering: Cannot reorder a query once a slice has been taken.я так понимаю их фильтры противоречат друг другу
def actions_list(request):
action = actions.objects.all()
paginator = Paginator(action, 50)
try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1
try:
contacts = paginator.page(page)
except (EmptyPage, InvalidPage):
contacts = paginator.page(paginator.num_pages)
return render_to_response('actions_list.html', {
'contacts':contacts,
},context_instance = RequestContext(request),)
{% load sorting_tags %}
<div class="pagination">
<p>{% if contacts.has_previous %}
<a href="?page={{ contacts.previous_page_number }}{% if order_by %}&Order_by={{ order_by }}{% endif %}"> << туда</a>
{% endif %}
{{ contacts.number }} из {{ contacts.paginator.num_pages }}.
{% if contacts.has_next %}
<a href="?page={{ contacts.next_page_number }}{% if order_by %}&Order_by={{ order_by }}{% endif %}">сюда >></a>
{% endif %}</p>
</div>
<table>
<tr>
<th>{% anchor date_create Дата/Время %}</th>
<th>{% anchor account_id Телефон %}</th>
<th>{% anchor act Акт %}</th>
<th>{% anchor service_id Служба %}</th>
<th>{% anchor status_code Статус %}</th>
<th>{% anchor description Комментарий %}</th>
</tr>
{% autosort contacts.object_list %} <!-- МАТЮКИ ССЫЛАЮТСЯ НА ЭТУ СТРОКУ -->
{% for list in contacts.object_list %}
<tr>
<td>{{list.date_create|date:"d-m-Y G:i:s"}}</td>
<td>{{list.account_id}}</td>
<td>{{list.act }}</td>
<td>{{list.service_id}}</td>
<td>{{list.status_code}}</td>
<td>{{list.description}}</td>
</tr>
{% endfor %}
</table>
Офлайн
Насколько я понимаю это решение не совместимо с стандартно паджинацией. Используйте django-pagination того же автора, что и django-sorting.
Офлайн
пробовал, эффект тот же :
Caught AssertionError while rendering: Cannot reorder a query once a slice has been taken.код вьюшки
def actions_list(request):
action = actions.objects.all()
return render_to_response('actions_list.html', {
'action':action,
},context_instance = RequestContext(request),)
{% load sorting_tags %}
{% load pagination_tags %}
<table>
<tr>
<th>{% anchor date_create Дата/Время %}</th>
<th>{% anchor account_id Телефон %}</th>
<th>{% anchor act Акт %}</th>
<th>{% anchor service_id Служба %}</th>
<th>{% anchor status_code Статус %}</th>
<th>{% anchor description Комментарий %}</th>
</tr>
{% autopaginate action 20 %}
{% autosort action %}<!-- МАТЮКИ ССЫЛАЮТСЯ НА ЭТУ СТРОКУ -->
{% for list in contacts.object_list %}
<tr>
<td>{{list.date_create|date:"d-m-Y G:i:s"}}</td>
<td>{{list.account_id}}</td>
<td>{{list.act }}</td>
<td>{{list.service_id}}</td>
<td>{{list.status_code}}</td>
<td>{{list.description}}</td>
</tr>
{% endfor %}
</table>
{% paginate %}
Отредактировано (Янв. 14, 2011 11:35:53)
Офлайн
чуток поправлю информацию :
эта ошибка возникает при попытке отсортировать столбец
django-pagination работает нормально
неужели все банально в том что сортировщик не может работать с срезами ? но как в таком случае его научить ?
Офлайн