Уведомления

Группа в Telegram: @pythonsu

#1 Янв. 13, 2011 15:47:52

sonniy
От:
Зарегистрирован: 2009-12-18
Сообщения: 84
Репутация: +  0  -
Профиль   Отправить e-mail  

django-sorting + paginator|проблемы|

вылазит вот такая вот беда:

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>
как устранить проблему или же есть другие способы ?



Офлайн

#2 Янв. 14, 2011 00:05:19

Ferroman
От:
Зарегистрирован: 2006-11-16
Сообщения: 2759
Репутация: +  1  -
Профиль   Отправить e-mail  

django-sorting + paginator|проблемы|

Насколько я понимаю это решение не совместимо с стандартно паджинацией. Используйте django-pagination того же автора, что и django-sorting.

Офлайн

#3 Янв. 14, 2011 10:49:43

sonniy
От:
Зарегистрирован: 2009-12-18
Сообщения: 84
Репутация: +  0  -
Профиль   Отправить e-mail  

django-sorting + paginator|проблемы|

пробовал, эффект тот же :

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)

Офлайн

#4 Янв. 14, 2011 16:08:39

sonniy
От:
Зарегистрирован: 2009-12-18
Сообщения: 84
Репутация: +  0  -
Профиль   Отправить e-mail  

django-sorting + paginator|проблемы|

чуток поправлю информацию :
эта ошибка возникает при попытке отсортировать столбец
django-pagination работает нормально
неужели все банально в том что сортировщик не может работать с срезами ? но как в таком случае его научить ?



Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version