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 some problem with the injecting of my cookie into login.php page. This
I have got some code to load an assembly and get all types, which
I've got some entities which have decimal properties on them. These entities' properties are
I have a project I am doing some maintenance work on and have got
I just got Delphi 2009 and have previously read some articles about modifications that
I have got the following problem since the server has safe mode turned on,
I'm implementing a project in MVP pattern and I've got some interfaces like this:
the problem is as follows: I have got a rendered bitmap in a byte
I am having problem in django. I have created a form in my app
I have got a abstract class which is implementing 3 interfaces. public abstract class

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.