# django User matching query does not exist

**URL:** <https://forum.djangoproject.com/t/django-user-matching-query-does-not-exist/12705>\
**Category:** Forms & APIs\
**Created:** [March 20, 2022, 11:56am UTC](https://forum.djangoproject.com/t/django-user-matching-query-does-not-exist/12705 "2022-03-20T11:56:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M2021SA](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/m2021sa/32/7847_2.png) [@M2021SA](https://forum.djangoproject.com/u/M2021SA)\
**Post date:** [March 20, 2022, 11:56am UTC](https://forum.djangoproject.com/t/django-user-matching-query-does-not-exist/12705/1 "2022-03-20T11:56:11Z")

</div>

when I try to login in from the form that i created in react.js and connected it with django i face error (User matching query does not exist.)  
I think the problem here in views.py but i couldn’t solve it for days

```auto
from django.http import JsonResponse, HttpResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.views import APIView
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from .serializers import UserSerializer
from .models import User

class UserList(generics.ListCreateAPIView):
    queryset = User.objects.all()
    serializer_class = UserSerializer
    #permission_classes = [IsAuthenticated]

class UserDetail(generics.RetrieveUpdateDestroyAPIView):
    queryset = User.objects.all()
    serializer_class = UserSerializer 
    #permission_classes = [IsAuthenticated] 

@csrf_exempt
def user_login(request):
    email = request.POST['email']
    password = request.POST['password']
    formValues = User.objects.get(email= email, password= password)

    if formValues:
        return JsonResponse ({'bool':True #, 'user_id':formValues.id
         })
    else:
        return JsonResponse ({'bool':False})

  

```

here is model.py

```auto
from django.contrib.auth.models import AbstractUser

from django.db import models

class User(AbstractUser):
    username = models.CharField(max_length=50, null=True , blank= True)
    email = models.EmailField(
        verbose_name='email address',
        max_length=255,
        unique=True,
    )
    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['username']
    
    
    def __str__ (self):
        return self.email
    
    def get_name(self):
        return self.username
        
    

```

errer from console

```auto
DoesNotExist at /api/user-login
User matching query does not exist.
Request Method:	POST
Request URL:	http://127.0.0.1:8000/api/user-login
Django Version:	4.0.3
Exception Type:	DoesNotExist
Exception Value:	
User matching query does not exist.
Exception Location:	/home/monerahalbeshry/.local/lib/python3.8/site-packages/django/db/models/query.py, line 496, in get
Python Executable:	/usr/bin/python3
Python Version:	3.8.10
Python Path:	
['/home/monerahalbeshry/Desktop/team10-backend/env/GoCourses',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '/home/monerahalbeshry/.local/lib/python3.8/site-packages',
 '/usr/local/lib/python3.8/dist-packages',
 '/usr/lib/python3/dist-packages']
Server time:	Sun, 20 Mar 2022 09:38:05 +0000

```

anyone to help please ☹

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 20, 2022, 12:19pm UTC](https://forum.djangoproject.com/t/django-user-matching-query-does-not-exist/12705/2 "2022-03-20T12:19:45Z")

</div>

What you’ve posted is not how a User logs in.

See the docs at

- [Using the Django authentication system | Django documentation | Django](https://docs.djangoproject.com/en/4.0/topics/auth/default/)  
and
- [Password management in Django | Django documentation | Django](https://docs.djangoproject.com/en/4.0/topics/auth/passwords/)

Also, in the future, please post the traceback from the console where you are running Django, not the error messages being displayed in the browser.
