Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:56:45+00:00 2026-06-03T01:56:45+00:00

I have a search view that allows user’s to search for their notecards, and

  • 0

I have a search view that allows user’s to search for their notecards, and then displays results paginated 6 at a time.

I use pagination in all my other views and it works correctly. However, when using it with the query it displays the first 6 results, displays “Page 1 of 2” and the next button, but when you click Next you get no results found.

I’ve setup the ‘*’ query as a search-all, and when I search for that query the first request call is:

http://127.0.0.1:8000/search/?q=*

When I click next, the call is:

http://127.0.0.1:8000/search/?page=2

The search url is:

url(r'^search/', 'notecard.search.views.search', name="search"),

The search view is:

@login_required(login_url='/auth/login/')
def search(request):
    query = request.GET.get('q', '')
    results = []
    notecard_list = []
    if query:
        if query == "*":
            results = Notecard.objects.filter(section__semester__user=request.user)
        else:
            results = Notecard.objects.filter(Q(section__semester__user=request.user), Q(notecard_body__icontains=query)|Q(notecard_name__icontains=query))
        paginator = Paginator(results, 6)

        try:
            page = int(request.GET.get('page', '1'))
        except ValueError:
            page = 1

        try:
            notecard_list = paginator.page(page)
        except (EmptyPage, InvalidPage):
            notecard_list = paginator.page(paginator.num_pages)
    return list_detail.object_list(
        request,
        queryset = Notecard.objects.filter(section__semester__user=request.user),
        template_name = "notecards/search.html",
        template_object_name = "results",
        extra_context = {"results": results, "notecard_list": notecard_list,},
    )

and the search template is:

{% extends "base.html" %}
{% block title %} Notecard List | {% endblock %}

{% block content %}
<div id='main'>
<table id='notecards'>
  <tr>
        <th class="name">Search Results</th>
  </tr>
</table>

<table id='known_split'>
        <p>Search results:<a class="edit" href="{% url semester_list %}">Back to Semesters</a></p>
            {% for result in notecard_list.object_list %}
                    <tr>
                        <td class="image">{% if result.known %}<img src="{{ STATIC_URL }}/images/known.png" width="41" height="40" />{% else %}<img src="{{ STATIC_URL }}/images/unknown.png" width="41" height="40" />{% endif %}</td>
                    <td class="text"><a href="{% url notecards.views.notecard_detail result.id %}">{{ result.notecard_name|truncatewords:9 }}</a></td>
                    </tr>
                {% endfor %}
</table>

<div class="pagination">
  <span class="step-links">
{% if notecard_list.has_previous %}
<a class="navlink" href="?page={{ notecard_list.previous_page_number }}">previous</a>
{% endif %}

<span class="current">
Page {{ notecard_list.number }} of {{ notecard_list.paginator.num_pages }}
</span>

{% if notecard_list.has_next %}
<a class="navlink" href="?page={{ notecard_list.next_page_number }}">next</a>
{% endif %}
  </span>
</div>

{% endblock %}

As I said, I use basically the same pagination in every other view successfully, so I have to believe this is due to the query somehow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:56:47+00:00Added an answer on June 3, 2026 at 1:56 am
    1. You’re not providing the q argument in the URL for page 2 (the URL should be something like http://127.0.0.1:8000/search/?q=*&page=2 instead)
    2. You should check out class based views (ListView to be more precise), which include pagination
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table view that should be filtered by values of search field
I have a search page that if there is results in the list it
I have a search page which allows users to further filter thier results based
I have written a c# win forms application that allows the user to open
I have a form that allows the user to perform a myriad of searches.
We're designing a WPF / MVVM application that allows the user to search and
I am trying to create a search function that allows the user to search
I'm making a simple search form in rails. In my search view I have
I have a search display controller in a table view. In this table view,
I have below html code in one of the opensource project. <form action=/wiki/bin/view/Main/Search> <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.