Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Profiling mượt mà trong Django với django-silk


django-silk cung cấp trang dashboard tại /silk/ hiển thị chi tiết: số request, query SQL, thời gian thực thi, v.v. Rất hữu ích cho production.

Cài đặt

  1. pip install django-silk

  2. Thêm middleware và app:

    MIDDLEWARE = [..., 'silk.middleware.SilkyMiddleware', ...]
    INSTALLED_APPS = [..., 'silk']
  3. URL: path('silk/', include('silk.urls', namespace='silk'))

  4. Chạy migration.

Sử dụng

Truy cập https://127.0.0.1:8000/silk/ để xem báo cáo profiling.