Skip to content

level_1 is done#1

Open
sleepwalkcapsule wants to merge 1 commit intomainfrom
level_1
Open

level_1 is done#1
sleepwalkcapsule wants to merge 1 commit intomainfrom
level_1

Conversation

@sleepwalkcapsule
Copy link
Owner

No description provided.

Copy link

@vppuzakov vppuzakov left a comment

Choose a reason for hiding this comment

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

👍 все верно, вмерживай


def welcome_user_view(request):
welcome_message = 'Bye, user'
welcome_message = 'Hello, user'

Choose a reason for hiding this comment

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

👍 верно

path('authorization/', authorization_view),
path('process-authorization/', process_authorization_view),
# добавлять пути тут
path('bye/', bye_user_view),

Choose a reason for hiding this comment

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

👍 верно, замапили путь на вьюху-обработчик

def is_username_banned_view(request, username: str):
# код писать тут
return HttpResponse('User not banned')
if username in BANNED_USERNAMES:

Choose a reason for hiding this comment

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

👍 верно

path('process-authorization/', process_authorization_view),
# добавлять пути тут
path('bye/', bye_user_view),
path('user-info/<int:user_id>/', get_user_info_view),

Choose a reason for hiding this comment

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

👍 используем path parameter с заданным типом при маппинге на вьюху

вызывалась вьюха get_month_title_view. Например http://127.0.0.1:8000/month-title/3/
"""

MONTHS = {

Choose a reason for hiding this comment

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

👍 словарь хорошо подходит для такой задачи


def get_month_title_by_number(month_number: int):
pass # код писать тут
if month_number in MONTHS:

Choose a reason for hiding this comment

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

👍 верно
💡 еще чтобы два раза не искать элемент в словаре, можно было бы использовать get метод словаря

return MONTHS.get(month_number)

if month_title:
return HttpResponse(month_title)
else:
return HttpResponseNotFound('Месяца с таким номером не существует') No newline at end of file

Choose a reason for hiding this comment

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

👍 верно

# добавлять пути тут
path('bye/', bye_user_view),
path('user-info/<int:user_id>/', get_user_info_view),
path('month-title/<int:month_number>/', get_month_title_view),

Choose a reason for hiding this comment

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

👍 все верно, задаем номер месяца как числовой path parameter

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

Comments