[PYTHON] Information recording memo using session in Django

How to retrieve recorded information from a session

Get as below, no need to think about definitions (If it is empty, it will be divided into cases in the subsequent processing). ``` variable= request.session.get('Session storage information variable name') ``` ``` ex) cart = request.session.get('cart') ```

How to add session information

Overwrite the session after adding additional information to the variable as shown below. ``` variable.append(Additional Information) request.session['Session storage information variable name'] =variable ``` ``` ex) cart.append(product_id) request.session['cart'] = cart ```

How to delete session information

Overwrite the session after creating a formal variable that does not have deletion information as shown below. ``` for mantissa(anything is fine)in variable: if mantissa!=Delete information: Formal variable.append(mantissa) request.session['Session storage information variable name'] =Formal variable ``` ``` ex) for p in cart: if p != product_id: filtered.append(p) request.session['cart'] = filtered ```

Recommended Posts

Information recording memo using session in Django
Deploy Django in 3 minutes using docker-compose
Extract information using File :: Stat in Ruby
CSS environment created in 10 minutes using Django
Ajax in Django (using generic class view)
Models in Django
Django Learning Memo
[Django memo] I want to set the login user information in the form in advance
django tutorial memo
Pass login user information to view in Django
Forms in Django
[Memo] Text matching in pandas data frame using flashtext
Ssh connection memo using ProxyCommand of ssh_config in Python
heroku deployment memo (Django)
Django 1.4.2 session key generation
Django memo # 1 from scratch
Model changes in Django
Try using Django templates.html
Memo using trigonometric functions
[Memo] Django development environment
How to update user information when logging in to Django RemoteUserMiddleware
A memo when creating a directed graph using Graphviz in Python
Write a co-author network in a specific field using arxiv information
Getting started and using sample class-based generic views in Django
How to generate a query using the IN operator in Django
A memo of writing a basic function in Python using recursion
Create an easy-to-use follow model in Django using ManyToManyField through