[Django]-What is the equivalent for assertDatabaseHas in Django

3👍

There’s no specific assertion for this.

You could perhaps use a general assertTrue along with the exists filter:

self.assertTrue(User.objects.filter(id=10).exists())

(Normally you’d use get() with an id query, but that doesn’t allow exists() and you’d have to catch the DoesNotExist exception if it’s not found.)

Leave a comment