[Fixed]-Django Testing – TypeError: argument of type model is not iterable

1👍

assertIn does what the name implies: it asserts that argument one is in argument two. But in your test for the detail view, you are passing resp.context['course'] as your argument two, which is not a list or container, it is a single instance.

You need to compare that the two are equal, not that one is in the other.

self.assertEqual(self.course, resp.context['course'])

Leave a comment