What is a 'Database Router' in Django, and in what scenario would you need to implement one?

Last updated 17 June 2026

  • A database router is a class that picks which DATABASES alias to use via db_for_read, db_for_write, allow_relation and allow_migrate.

  • Use one for primary/replica read-write splitting, separating apps or shards into different databases, or routing models to a legacy DB.

  • Enable it in DATABASE_ROUTERS. Beware replication lag and send read-after-write queries to the primary.

  • https://www.geeksforgeeks.org/python/django-interview-questions/
  • https://foysalff.medium.com/12-advanced-django-interview-questions-for-experienced-developers-dbe654e21a45
  • https://www.careers360.com/courses-certifications/articles/django-interview-questions-and-answers
  • https://www.interviewbit.com/django-interview-questions/
  • https://www.youtube.com/watch?v=OuBUUkQfBYM
  • https://www.placementpreparation.io/blog/django-interview-questions-for-freshers/
All Django interview questions