Complete the code to create a test client instance in Django.
from django.test import [1] client = [1]()
The Client class is used to simulate a user interacting with the Django application in tests.
Complete the code to send a GET request to the home page using the test client.
response = client.[1]('/')
The get method sends a GET request to the specified URL.
Fix the error in the assertion to check the response status code is 200.
assert response.status_code [1] 200
To verify the response was successful, the status code should be exactly 200.
Fill both blanks to test a POST request with data and check the response status code.
response = client.[1]('/submit/', data=[2]) assert response.status_code == 302
Use post to send data and a dictionary with form data for the POST request.
Fill all three blanks to test a view that requires login, using the client to login and then access a protected page.
client.[1](username='user', password='pass') response = client.[2]('/dashboard/') assert response.status_code [3] 200
Use login to authenticate, get to request the page, and == to check the status code.