[Fixed]-Django test client response context None


You need to add the test setup statement.

import django

Find more details by following my link:

👤Joe J


From Django documentation:

Although * your code * [+] would work in the Python interactive interpreter, some of the test client’s functionality, notably the template-related functionality, is only available while tests are running. The reason for this is that Django’s test runner performs a bit of black magic in order to determine which template was loaded by a given view. This black magic (essentially a patching of Django’s template system in memory) only happens during test running.

So if you run it in a test run, it should work.

You can see this question

Leave a comment