-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #427
base: master
Are you sure you want to change the base?
Develop #427
Conversation
Ihor-MA
commented
Sep 26, 2023
•
edited
Loading
edited
num_visits = request.session.get("num_visits", 0) | ||
request.session["num_visits"] = num_visits + 1 | ||
|
||
context = { | ||
"num_drivers": num_drivers, | ||
"num_cars": num_cars, | ||
"num_manufacturers": num_manufacturers, | ||
"num_visits": num_visits + 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it work correctly, you add 1 for two times? Also, you can try to use dict setdefault() method here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works well, in request.session["num_visits"] = num_visits + 1, we add 1 to 'num_visits' in Session data, in the context we add 1 to show user the variable num_visits' before the page reloads. if we use "num_visits": num_visits , we will see 0 times in the page, however in in Session data 'num_visits' will be 1. It was shown in video, so i think it is good solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GJ!