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

  • Home
  • SEARCH
  • 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 4099224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:24:21+00:00 2026-05-20T20:24:21+00:00

I have created a Django application. There is a filtering functionality in my application.

  • 0

I have created a Django application. There is a filtering functionality in my application. The filtered data is shown in a separate page.

Now I want to give Django Pagination to the filtered list page. While doing it, I came into this error. The pagination is shown at the bottom of the page with showing the correct number of pages NEXT.

But while clicking on the ‘Next Page’ in paginator it redirects me to my home page (/employeeList).

I suppose it is because of an HttpResponseRedirect (return HttpResponseRedirect('/employeeList')) I give inside the filter() which is used in some cases. I will paste my filter() and the HTML for pagination.

def filter(request):
    val2=''
    val3=''
    newData=''
    if request.GET.has_key('choices'):
        val2=request.GET.get('choices')

    if request.GET.has_key('textField'):
        val3=request.GET.get('textField')

    if request.POST:
        val2=request.POST.get('choices')
        val3=request.POST.get('textField')
    if val2=='Designation':
        newData = EmployeeDetails.objects.filter(designation=val3)
        flag=True
    elif val2=='Name':
        newData = EmployeeDetails.objects.filter(userName__icontains=val3)
        flag=True
    elif val2=='EmployeeID':
        newData = EmployeeDetails.objects.filter(employeeID=val3)
        flag=True
    elif val2=='Project':
        newData = EmployeeDetails.objects.filter(project=val3)
        flag=True
    elif val2=='DateOfJoin':
        newData = EmployeeDetails.objects.filter(dateOfJoin=val3)
        flag=True
    else:
        return HttpResponseRedirect('/employeeList')

    if request.POST.get('sortAscendValue'):
        newData = newData.order_by('userName')
    elif request.POST.get('sortDescendValue'):
        newData = newData.order_by('-userName')
    paginator = Paginator(newData, 10)
    try:
         page = int(request.GET.get('page', '1'))
    except ValueError:
        page = 1
    try:
        contacts = paginator.page(page)
    except (EmptyPage, InvalidPage):
        contacts = paginator.page(0)

    return render_to_response('filter.html',{'newData':newData,'emp_list': contacts,'val2':val2,'val3':val3,'flag':flag,'emp_list': contacts})

filter.html

<div class="pagination" >
    <span class="step-links">
        {% if emp_list.has_previous %}
            <a href="?page={{ empl_list.previous_page_numbe }}">Previous</a>
        {% endif %}

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

        {% if emp_list.has_next %}
            <a href="?page={{ emp_list.next_page_number }}">Next</a>
        {% endif %}
    </span>
</div>
  • 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-05-20T20:24:21+00:00Added an answer on May 20, 2026 at 8:24 pm

    try

    {% if emp_list.has_next %}
      <a href="?page={{ emp_list.next_page_number }}&choices={{ val2 }}>Next</a>
    {% endif %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a django app. Now i want to test the application's performance
I would like to deplay a django application/project, which i have created within Aptana.
I have recently created a version control page from my application to manage the
I created a django application with a user login/registration page. I am trying to
In my Django application I have Guest user accounts that are created for all
I have a django application and what I want to do is change wherever
I have a Django application that reads data from a web API and puts
So I have a django project I just created called 'coolprojectsite' the directory structure
I have created a JSP / servlets application running in Tomcat 7. It runs
I have created an android application that calls (using kSOAP library) a SOAP based

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.