Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Develop #427

wants to merge 2 commits into from

Conversation

Ihor-MA
Copy link

@Ihor-MA Ihor-MA commented Sep 26, 2023

image
image
image

Comment on lines +16 to +23
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,

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

Copy link
Author

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

Copy link

@obohatov obohatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants