Code Monkey home page Code Monkey logo

dj-pagination's Issues

When PAGINATION_DISABLE_LINK_FOR_FIRST_PAGE is True, the page 1 url links to the current page.

When PAGINATION_DISABLE_LINK_FOR_FIRST_PAGE is True, the href for the anchor tag for the number 1 page is blank. What this means is, when you click on the number 1, you just stay on the current page instead of going to page 1.

Look at this snippet of generated html. We are on page 4. If you hover over the number 1, the tooltip will show /current/path/?page=4. And, if you click on the number 1, nothing happens. You stay on the current page.

<div class="pagination">
  <a href="?page=3" class="prev">‹‹ previous</a>
  <a href="" class="page">1</a>
  <a href="?page=2" class="page">2</a>
  <a href="?page=3" class="page">3</a>
  <span class="current page">4</span>
  <a href="?page=5" class="page">5</a>
  <a href="?page=6" class="page">6</a>
  ...
  <a href="?page=8585" class="page">8585</a>
  <a href="?page=8586" class="page">8586</a>
  <a href="?page=5" class="next">next ››</a>
</div>

The problem is, the href for page 1 is blank. I think the bug is here, on line 25 of pagination.html.

{% if disable_link_for_first_page and page == 1 %}
<a href="{{ request.path }}{% if getvars %}?{{ getvars|slice:"1:" }}{% endif %}" class="page">{{ page }}</a>

I think there is another instance of the same problem on line 7 of pagination.html. When you are on page 2, the href for the anchor for the word "previous" is also blank. So if you are on page 2, and you click "previous", you stay on page 2.

previous issue

I'll make a video of the problem and you can see it
https://youtu.be/1UlJlZWUcyM
when i next page is success,but i previous page 1 is wrong,i can't previous page 1,only previous page 2
how can i fix that?
thanks

Django 1.10 compatibility

Hi Daniel! Good to see someone actively maintaining my go-to pagination package. One thing I've noticed - dj-pagination isn't yet compatible with 1.10, raising the following error:

TypeError: render_to_string() got an unexpected keyword argument 'context_instance'

which is expected since 1.10 removed that kwarg. I've sent a PR to zyga's repo, unfortunately it looks like it isn't maintained anymore.
I see you've already cleaned up Travis config, so how do you feel about code changes for 1.10? Do you want me to send a similar (but shorter) PR here?

About pagination.html path

i hope give a choose that use the pagination.html in the project(like in templates),
it will easy to extend and move to server

Add option SHOW_FIRST_PAGE_WHEN_INVALID

It would be very useful to have an option to default to the first page if hitting a wrong page object.

I suggest to basically replace https://github.com/pydanny/dj-pagination/blob/master/dj_pagination/templatetags/pagination_tags.py#L186-L196 with something like this:

    try:
        page_obj = paginator.page(request.page(page_suffix))
    except InvalidPage:
        if INVALID_PAGE_RAISES_404:
            raise Http404(
                "Invalid page requested.  If DEBUG were set to "
                + "False, an HTTP 404 page would have been shown instead."
            )
        if SHOW_FIRST_PAGE_WHEN_INVALID
            # fallback to first page
            page_obj = paginator.page(1)
        else:
            context[key] = []
            context["invalid_page"] = True
            return ""

Sometimes the {% paginate using 'mypath\pagination.html' %} was no useful

When I used the function like {% paginate using 'mypath\pagination.html' %}.
I used the same setting and code,it worked on my windows10 compute, but on my Ubuntu system compute it was no useful.
I used below code, please review, thanks very much!

...
{% block content %}
    {% autopaginate object_list 5 as object_list_list %}
    {% for object in object_list_list %}
        ...
    {% endfor %}
    <div class="paginate">
        {% paginate using 'pagination\article\pagination.html' %}  # This DTL can't work
    <div>
{% endblock content %}
...

Current setup_requires can cause Django 2.0 to install on Python 2

I maintain a few legacy Django projects which are not yet on Python 3 (don't worry, it's going to happen). The current setup_requires has caused Django 2.0 to attempt to install on these Python 2 installations when doing a pip install dj-pagination or even a pip install -r requirements.txt if Django 1.11.x is not already installed.

I've made a PR #14 which uses extras_require instead of setup_requires to enforce the conditional dependencies and ensure Django 2.0 does not install on Python 2

How do I add gap between the page numbers displayed at the bottom?

I use {% paginate %} at the bottom of a table and it works perfectly, but the page numbers are too close to each other. I see that we can do {% paginate using 'template.html' %}, but I'm unsure how to use that to create a distance between the page number displayed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.