[Django]-Django test client gets 404 for all urls


Keep in mind that most views use something like get_object_or_404, get_list_or_404, or simply raise Http404 when there’s a problem accessing some object or another. You’ll need to make sure that your test database is populated with sufficient objects to fulfill all these requirements to make the view not return a 404.

Remember, when running tests, the database is rolled back after each test (using transactions), so each test method must stand on its own or the setUp method must populate the database with any required dependencies.

Leave a comment