Skip to content

New Project - Hotel#1

Open
SEkaya13 wants to merge 3 commits intomainfrom
feature/hotel
Open

New Project - Hotel#1
SEkaya13 wants to merge 3 commits intomainfrom
feature/hotel

Conversation

@SEkaya13
Copy link
Owner

No description provided.

&& rm -rf /var/lib/apt/lists/*

# Копируем requirements.txt
COPY ../requirements.txt .

Choose a reason for hiding this comment

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

Нужно использовать poerty или uv
В этом проекте пусть останется, но в следующем другоц пакетный менеджер

hotel/Dockerfile Outdated
EXPOSE 8000

# Запускаем сервер
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] 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.

посмотри про ключ workers

@@ -0,0 +1,40 @@
services:
db:
image: postgres:15

Choose a reason for hiding this comment

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

лучше использовать более новую версию постгри

# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-qd92hjb#a)qrwivifedzj@+lgvpwzn5c065ab@6x9v@ow236%_'

Choose a reason for hiding this comment

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

Такое нельзя защивать в код, это нужно брать из переменных окружения

Copy link
Owner Author

Choose a reason for hiding this comment

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

Я в сетинге особо не менял, поэтому откуда там secret key я не шарю, не совсем понял про то, что надо брать из переменных окружения.

# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases

DATABASES = {

Choose a reason for hiding this comment

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

а чего тут не постгрес?
sqlite не используют в прод средах

Choose a reason for hiding this comment

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

В докер компоуз у тебч постгря

id = models.AutoField(primary_key=True)
description = models.TextField()
price = models.IntegerField()
date_create = models.DateTimeField(auto_now_add=True)

Choose a reason for hiding this comment

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

стоит добавить поля created_at и updated_at

id = models.AutoField(primary_key=True)
room = models.ForeignKey(HotelRooms, on_delete=models.CASCADE)
check_in_date = models.DateField()
check_out_date = models.DateField()

Choose a reason for hiding this comment

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

стоит добавить поля created_at и updated_at

path('rooms/add/', views.add_room, name='add_room'),
path('rooms/<int:room_id>/delete/', views.delete_room, name='delete_room'),
path('rooms/<int:room_id>/bookings/', views.get_reservations, name='list_reservations'),
path('bookings/create/', views.create_reservation, name='create_booking'),

Choose a reason for hiding this comment

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

Почитай про принципы REST , глаголы не принято использовать

Choose a reason for hiding this comment

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

Дальше там тоже есть такие же ошибки

def index(request):
return JsonResponse({'message': 'Hotel API is running'})

def get_room_detail(request, room_id):

Choose a reason for hiding this comment

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

Лучше использовать уже встроенные джанго классы. Посмотри CBV и давай сделаем апишку через Django REST Framework


urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/hotel/', HotelRoomsList.as_view()),

Choose a reason for hiding this comment

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

обычно пишется во множественно числе hotels

path('admin/', admin.site.urls),
path('api/v1/hotel/', HotelRoomsList.as_view()),
path('api/v1/hotel/<int:pk>/', HotelRoomsUpdate.as_view()),
path('api/v1/hoteldelete/<int:pk>/', HotelRoomsDestroy.as_view()),

Choose a reason for hiding this comment

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

глаголы не по REST принципу

COPY ../requirements.txt .

# Устанавливаем Python зависимости
RUN pip install -r requirements.txt uvicorn

Choose a reason for hiding this comment

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

а чего тут uvicorn отдельно стоит ?

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