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 4039420
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:36:33+00:00 2026-05-20T12:36:33+00:00

i have got some problem on implementing Django sessions. I have an employee listing

  • 0

i have got some problem on implementing Django sessions. I have an employee listing page with a filter option on it. Filtering is done based on the fields and a text entered in a text box. The users filtered is displayed in the filter.html page; clicking on the user name takes to that user’s profile page. Now i want to go back to the previous page (given a back button in the employee profile page) where the filtered users were displayed(filter.html). I guess this could be done by sessions. But i am not sure the way i use sessions is correct. Please help me to solve this as i am new to Django. Will post my code here:

def filter(request):
    val=request.POST.get('designation')      
    val2=request.POST.get('choices')
    val3=request.POST.get('textField')

    if val2=='Designation':                
        newData = EmployeeDetails.objects.filter(designation=request.POST.get('textField'))  
        request.session['session_textField']="textField"  
        request.session['session_choices']="choices"    
        session_textField = request.session["session_textField"]
        session_choices = request.session["session_choices"]
        print session_textField,session_choices
    elif val2=='Name':
        newData = EmployeeDetails.objects.filter(userName=request.POST.get('textField'))
        request.session['session_textField']="textField"  
        request.session['session_choices']="choices"      
        session_textField = request.session["session_textField"]
        session_choices = request.session["session_choices"]
        print session_textField,session_choices        
    elif val2=='EmployeeID':
        newData = EmployeeDetails.objects.filter(employeeID=request.POST.get('textField'))        
        request.session['session_textField']="textField"  
        request.session['session_choices']="choices"      
        session_textField = request.session["session_textField"]
        session_choices = request.session["session_choices"]
        print session_textField,session_choices  
    elif val2=='Project':
        newData = EmployeeDetails.objects.filter(project=request.POST.get('textField'))     
        request.session['session_textField']="textField"  
        request.session['session_choices']="choices"      
        session_textField = request.session["session_textField"]
        session_choices = request.session["session_choices"]
        print session_textField,session_choices     
    elif val2=='DateOfJoin':
        newData = EmployeeDetails.objects.filter(dateOfJoin=request.POST.get('textField'))       
        request.session['session_textField']="textField"  
        request.session['session_choices']="choices"      
        session_textField = request.session["session_textField"]
        session_choices = request.session["session_choices"]
        print session_textField,session_choices   
    else:
        return render_to_response('filter.html') 

    return render_to_response('filter.html',{'newData':newData,'val2':val2}) 

Filter.html

<html>
<h3><br><br>
The Filtered Data 
</h3>
<body>
<br>
{%for data in newData%}
<a href ="http://10.1.0.90:8080/singleEmployee/{{data.id}} ">
{{ data.userName}}<br>
{%endfor%} 
</body><br><br><br><br>
<a href ="http://10.1.0.90:8080/employeeList/ "> Home Page  </a>
</html>

Employee Profile html page

<table>
<tr> <td>Name: {{ empSelect.userName }} </td> </tr><td>
<tr> <td>Designation: {{ empSelect.designation }} </td> </tr><td>
<tr> <td>Employee ID: {{ empSelect.employeeID }} </td> </tr><td>
<tr> <td>Contact Number: {{ empSelect.contactNumber }} </td> </tr><td>
<tr> <td>Project: {{ empSelect.project }} </td> </tr><td>
<tr> <td>Date Of Join: {{ empSelect.dateOfJoin }} </td> </tr><td>
</table></h4><br>
<input type="submit" value="Delete User" onClick="window.location.href='/userDelete/{{empSelect.id}}'"/>
<input type="submit" value="Update User" onClick="window.location.href='/userUpdate/{{empSelect.id}}'"/>
</div><br><br>
<a href ="http://10.1.0.90:8080/filter/{{emp.id}} "> Back  </a><br><br>
<a href ="http://10.1.0.90:8080/employeeList/ "> Home Page  </a>
</body></html>

If the code i provided has a lot of error, please help me to correct it.

  • 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-20T12:36:33+00:00Added an answer on May 20, 2026 at 12:36 pm

    It’s not at all clear what you are trying to do. But notice this:

    request.session['session_textField']="textField"  
    request.session['session_choices']="choices"   
    

    These two lines, which are identical in every block, simply set the two session variables to the strings “textField” and “choices”. I don’t think this is what you want to do, although as I say above I don’t know exactly what you do want to do. However, this seems to be an elementary programming problem, not anything to do with Django sessions in particular.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got some problem implementing bullet physics into my opengl game. The thing
I have some problem with Jquery Autocomplete plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ ) I got it
I've got some problem, I have list of data in the file: 053-37878 03828008
I have some problem to get the Google Analytics to work. I have got
i have a problem, I got some li, inside them i have a link
I'm a beginner in Java and I have got some problems with the static
I have got some javascript code and I'd like to convert this to C#.
I've got some Columns in a DataGridView that have their Binding property set to
I've got some 3rd party beans that have method signatures that fit quite well
I have got Sinatra/Rails app and an action which starts some long process. Ordinary

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.