Q1. How would you design a multi-tenant Django API where each tenant has strict data isolation?
I would model tenant identity at the request boundary, enforce row-level access in every query path, and back it with database constraints where possible. For larger scale, I would evaluate schema-per-tenant vs shared-schema with tenant keys based on isolation needs, operational cost, and migration complexity.
Q2. What is your strategy for preventing N+1 query issues in Django REST APIs?
I profile query counts first, then use select_related for one-to-one or foreign key joins and prefetch_related for many-to-many collections. I also keep serializer logic explicit so expensive nested relations are only loaded when the endpoint truly needs them.
Q3. How do you run safe background processing for long-running jobs in a Django system?
I move expensive work into task queues (for example Celery) with idempotent tasks, retries, and dead-letter handling. The API returns immediately with job state, and I expose progress/status endpoints so users can track completion without blocking web workers.