[Fixed]-Django field doesn't remain incremented even after calling save()


You need to reload your local version of card back from the database after you call the view. Otherwise they have nothing to do with each other, and card has no way of knowing that the db has been updated.

resp = self.client.post(reverse('check_answer'), data=data)
card = Card.objects.get(id=card.id)
self.assertEqual(card.score, 1)

Leave a comment