Ошибка 500 - Внутренняя ошибка сервера на Django на производственном сервере

Я столкнулся с проблемой, когда мое приложение Django работает в производстве на CPanel, и я использую Passenger для WSGI. Приложение отлично работает на локальной машине, но на живом сервере работает только корневой маршрут (/), а все остальные маршруты возвращают 500 - Internal Server Error. Я не смог определить, в чем причина проблемы.

Примечание: даже такой тестовый маршрут возвращает ошибку 500 на живом сервере: path('test/', lambda request: HttpResponse('Test route works!')),

Main URL.py

from django.urls import include, path
from django.http import HttpResponse
urlpatterns = [
    path('', include('accommodation.urls')),
    path('test/', lambda request: HttpResponse('Test route works!')),#This works only on local machine
]

Accommodation URL.py

from django.urls import path
from .views.dashboard_view import dashboard
from .views.booking_view import newBooking,manageBooking,walk_in,walk_in_checkin,check_out,book_workspace,book_room,check_in,booking_requests,get_booking_request_details,delete_booking_request,workspace,check_bed_availability
from .views.guest_view import new_client,new_guest,manageClient,manageGuest,update_guest,delete_guest
from .views.room_view import roomList,room_and_bed_availability,roomMaintenance,stayView,stay_data,dirtyRoom,clean_bed
from .views.settings_view import add_site,manageSite,roomCategory,addRoomCategory,editRoomCategory,bedManagement,addBed,roomManagment, workspaceManagment
from .views.finance_view import Debits,payments,mark_as_paid,completedPayments,rates,processReport,costCenter
from .views.incidents_medical import incidents,medical_cases,add_incident,add_case
from .views.reports_view import generate,generate_report
from .views.miscellaneous_view import meals,vehicleRent


urlpatterns = [

    # Dashboard Routes
    path('', dashboard, name='accommodation_dashboard'), #only this works on live server
    
    #Booking Routes
    path('new_booking/', newBooking, name='new_booking'),
    path('new_booking/book/', book_room, name='book_room'),
    path('manage_booking/', manageBooking, name='manage_booking'),
    path('manage_booking/check_in/<int:booking_id>/', check_in, name='check_in'),
    
    
    path('online_request/', booking_requests, name='online_request'),
    path('online_request/<int:booking_id>/', get_booking_request_details, name='get_booking_request_details'),
    path('online_request/check_bed_availability/<int:bed_id>/<str:checkin_date>/<str:checkout_date>/', check_bed_availability, name='check_bed_availability'),
    path('delete_booking_request/<int:booking_id>/', delete_booking_request, name='delete_booking'),
    path('booking/workspace', workspace, name='workspace'),
    
    #Check-in Routes
    path('check_in/', walk_in, name='check_in'),
    path('check_in_checkin/', walk_in_checkin, name='check_in_checkin'),
    path('check_out/', check_out, name='check_out'),
    ]

Settings.py

passenger_wsgi.py

import sys
import os
import logging
import traceback

# Configuração de log
logging.basicConfig(
    level=logging.ERROR,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    filename='/home/myuser/public_html/accommodation/wsgi_error.log'
)

try:
    # Adicionar projeto ao path
    sys.path.insert(0, '/home/myuser/public_html/accommodation')
    
    # Configurar Django
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
    
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()

except Exception as e:
    # Log detalhado de qualquer erro de configuração
    logging.error("WSGI Setup Error:")
    logging.error(traceback.format_exc())
    raise
Вернуться на верх