-
Notifications
You must be signed in to change notification settings - Fork 31
level_2 #3
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
base: main
Are you sure you want to change the base?
level_2 #3
Conversation
| products = [] | ||
| # код писать тут | ||
| for product in PRODUCTS: | ||
| type = request.GET.get('type') |
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.
type – это билдин-функция, не надо так называть переменную
| def get_products_view(request): | ||
| products = [] | ||
| # код писать тут | ||
| for product in PRODUCTS: |
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.
Если тип продукта не указан, от цикла вообще можно избавиться. Совсем идеально было бы тут использовать лист компрехеншн.
| if request.method == 'POST': | ||
| data = json.loads(request.body) | ||
| # код писать тут | ||
| print(data) |
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.
Это тут лишнее
| data = json.loads(request.body) | ||
| # код писать тут | ||
| print(data) | ||
| for username, password in USERNAME_TO_PASSWORD_MAPPER.items(): |
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.
Если в словаре пользователей будет много элементов, каждый раз придётся итерироваться по всем. Попробуй переписать так, чтобы этого цикла не было.
No description provided.