Title: requestsession not working in Django to pass html form variable to another function
Tags: python;html;django;request
Question: I am trying to use request.session to pass a html form variable into another function in Django, I am currenlty having trouble because the result from the session is resulting in None. Would appreciate help fixing it or another suggestion to pass the html form variable from to another function as a string.
Here is my views.py file
def home(request):
input_email = request.POST.get('emailvalue')
request.session["input_email"] = input_email
return render(request, 'file1.html')
def pre_que_ip(request):
actual_email = request.session["input_email"]
print(actual_email)
urls.py
path('admin/', admin.site.urls),
path('', views.home, name = 'login'),
path('home/', views.home, name = 'home'),
path('add_ipaddress/', views.pre_que_ip, name = 'pre_que_ip')
file1.html
<form action="/add_ipaddress/" method="post"&gt;
{% csrf_token %}
<input type="text" name="emailvalue" required&gt;<br&gt;<br&gt;
<input type="submit" value="Submit"&gt;<br&gt;<br&gt;
</form&gt;
Comment: Have you tried printing the contents in the post variable and printing the request session variable right after assignment, is any of them empty?

Comment: Which [session engine](https://docs.djangoproject.com/en/3.0/topics/http/sessions/#configuring-the-session-engine) are you using and can you include the relevant configuration from the `settings.py` file?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:02/28/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><html><django><request>', 'Title': 'requestsession not working in Django to pass html form variable to another function', 'ViewCount': 15, 'id': 60459037, 'user_AboutMe': None, 'user_AccountId': 16924728.0, 'user_DisplayName': 'Jeremy Lin', 'user_Reputation': 248.0, 'user_Views': 23.0, 'user_id': 12240644.0}}