[Django]-How do I setup a unit test user for django app? The unit test can't login

45👍

The following code inserted at the beginning of the testcase creates a user, logs them in, and allows the rest of the test to contiue

self.user = User.objects.create_user(username='testuser', password='12345')
login = self.client.login(username='testuser', password='12345')

Leave a comment