[Answered ]-How to get django to authenticate during unit testing

2👍

It’s very simple:

c = Client()
c.login(username='fred', password='secret')

https://docs.djangoproject.com/en/1.4/topics/testing/#django.test.client.Client.login

And you should modify your view:

from django.contrib.auth.decorators import login_required

@login_required
def get_queryset(self):
    ...

Leave a comment