Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error 'AdminCursorPaginator' object has no attribute 'get_elided_page_range' #4

Closed
danaki opened this issue Apr 25, 2022 · 3 comments

Comments

@danaki
Copy link

danaki commented Apr 25, 2022

class PostingAdmin(CursorPaginatorAdmin):
    cursor_ordering_field = '-posting_id'
    list_display = (
        'posting_id',
...
    )
INSTALLED_APPS = [
    'grappelli',
    'backend',
    'auditlog',
    'etc',
    'smart_selects',
    'django_extensions',
    'django.contrib.admin',
    'admin_cursor_paginator',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
@a1tus
Copy link
Owner

a1tus commented May 4, 2022

Hello. I suppose it happens because of grapelli. This method is not called from custom template tag in change_list.html:

{% block pagination %}{% admin_cursor_pagination cl %}{% endblock %}

@danaki
Copy link
Author

danaki commented Aug 12, 2022

It is produced by this line:

page_range = cl.paginator.get_elided_page_range(cl.page_num) if pagination_required else [] 

django/contrib/admin/templatetags/admin_list.py, line 51

where cl is

<admin_cursor_paginator.views.CursorPaginatorChangeList object at 0x11017fa60>

@danaki
Copy link
Author

danaki commented Aug 12, 2022

Modifying template this way fixes the error for grappelli:

{% extends 'admin/change_list.html' %}

{% load admin_cursor_paginator_tags %}

{% block pagination_top %}
{% admin_cursor_pagination cl %}
{% endblock %}

{% block pagination_bottom %}
{% admin_cursor_pagination cl %}
{% endblock %}

{% block pagination %}{% admin_cursor_pagination cl %}{% endblock %}

I'll try to override it locally.

@danaki danaki closed this as completed Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants