Querying the database in a Django unit test
1
I am creating a web application which has a POST endpoint, that does two things: Saves the POST ed data (a university review) in the database. Redirects the user to an overview page. Here is the code for it: if request.method == 'POST': review = Review(university=university, user=User.objects.get(pk=1), summary=request.POST['summary']) review.save() return HttpResponseRedirect(reverse('university_overview', args=(university_id,))) I haven't yet implemented passing the user data to the endpoint, and that's why I'm saving everything under the user with pk=1 . My test is as follows: class UniversityAddReviewTestCase(TestCase): def setUp(self): user = User.objects.create(username="username...