Skip to content

Commit 25dfa27

Browse files
committed
Standardizes Dockerfile syntax and enforces queryset ordering
Updates the Dockerfile to use consistent capitalization in the `AS` keyword and modifies the `CMD` instruction to use an array format for better reliability. Enforces default ordering by `id` for `Employee` and `Department` querysets to ensure consistent API responses.
1 parent 310adb8 commit 25dfa27

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
88

99
ARG PYTHON_VERSION=3.12
10-
FROM python:${PYTHON_VERSION}-slim as base
10+
FROM python:${PYTHON_VERSION}-slim AS base
1111

1212
# Prevents Python from writing pyc files.
1313
ENV PYTHONDONTWRITEBYTECODE=1
@@ -51,4 +51,4 @@ EXPOSE 8000
5151
# Run the application.
5252
# Test application
5353
# RUN python test_project/manage.py makemigrations && python test_project/manage.py migrate
54-
CMD gunicorn --workers=2 test_project.wsgi --bind 0.0.0.0:8000
54+
CMD ["gunicorn", "--workers=2", "test_project.wsgi", "--bind", "0.0.0.0:8000"]

apidemo/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class EmployeeViewSet(viewsets.ModelViewSet):
1111
API endpoint that allows employees to be viewed or edited.
1212
Supports filtering, searching, ordering, and pagination.
1313
"""
14-
queryset = Employee.objects.all()
14+
queryset = Employee.objects.all().order_by("id")
1515
serializer_class = EmployeeSerializer
1616
filter_backends = [filters.SearchFilter, filters.OrderingFilter]
1717
search_fields = ["first_name", "last_name", "department__title"]
@@ -25,7 +25,7 @@ class DeptViewSet(viewsets.ModelViewSet):
2525
API endpoint that allows departments to be viewed or edited.
2626
Supports searching, ordering, and pagination.
2727
"""
28-
queryset = Department.objects.all()
28+
queryset = Department.objects.all().order_by("id")
2929
serializer_class = DepartmentSerializer
3030
filter_backends = [filters.SearchFilter, filters.OrderingFilter]
3131
search_fields = ["title"]

0 commit comments

Comments
 (0)