# What should \`django.contrib.auth.login(request, None)\` do?

**URL:** <https://forum.djangoproject.com/t/what-should-django-contrib-auth-login-request-none-do/32525>\
**Category:** Django Internals\
**Created:** [June 27, 2024, 6:56pm UTC](https://forum.djangoproject.com/t/what-should-django-contrib-auth-login-request-none-do/32525 "2024-06-27T18:56:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaap3](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jaap3/32/22281_2.png) [@jaap3](https://forum.djangoproject.com/u/jaap3)\
**Post date:** [June 27, 2024, 6:56pm UTC](https://forum.djangoproject.com/t/what-should-django-contrib-auth-login-request-none-do/32525/1 "2024-06-27T18:56:44Z")

</div>

Without looking at the docs or implementation. What do you expect to happen when the following code handles a request?

```auto
from django.contrib.auth import login

def my_view(request):
    login(request, None)

```

a. Logs out the current logged, or nothing if no user is logged in  
b. TypeError  
c. Does noting  
d. It depends on the state of the request  
e. AttributeError

The answer is in this Django ticket: [#35530 (`django.contrib.auth.login` inconsistently guards `request.user`) – Django](https://code.djangoproject.com/ticket/35530#comment:3)
