Skip to content

Conversation

@mishakov1c
Copy link

No description provided.

products = []
# код писать тут
for product in PRODUCTS:
type = request.GET.get('type')
Copy link
Contributor

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:
Copy link
Contributor

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)
Copy link
Contributor

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():
Copy link
Contributor

Choose a reason for hiding this comment

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

Если в словаре пользователей будет много элементов, каждый раз придётся итерироваться по всем. Попробуй переписать так, чтобы этого цикла не было.

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.

2 participants