# Django - map auth0 user onto existing users in sqlite database

**URL:** <https://community.auth0.com/t/django-map-auth0-user-onto-existing-users-in-sqlite-database/20335>\
**Category:** Get Help\
**Created:** [January 22, 2019, 11:47am UTC](https://community.auth0.com/t/django-map-auth0-user-onto-existing-users-in-sqlite-database/20335 "2019-01-22T11:47:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludovico](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ludovico](https://community.auth0.com/u/ludovico)\
**Post date:** [January 22, 2019, 11:47am UTC](https://community.auth0.com/t/django-map-auth0-user-onto-existing-users-in-sqlite-database/20335/1 "2019-01-22T11:47:43Z")

</div>

I’m trying to integrate auth0 with my existing django app and sqlite database. Login is working, the problem is I can’t get the usernames inputted by auth0 through request to map on to the user models already present in my db.

I have hardcoded my auth0 backend to return the user details `{'username':'eq3', 'user_id':21`

However when I go to views.py and put a `print(request.user.username)` and `print(request.user.id)` it prints `eq306fa23456g204e8c` and `51` . When I go into my database, I see that it has indeed created a new user in the auth\_user table, even though there’s already a user with eq3 and user id 21 in the same table. Furthermore, if I input a random username such as `foobar` , it will still create a new user, but it won’t add the nonsensical alphanumeric string to the username, just `foobar` . What is going on here? How can I get django to recognize that the username eq3 is already in the database and thus use that as the user from which to retrieve data for the app??

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 22, 2019, 3:32pm UTC](https://community.auth0.com/t/django-map-auth0-user-onto-existing-users-in-sqlite-database/20335/2 "2019-01-22T15:32:06Z")

</div>

Hey @ludovico!

I’m not sure how it works with Python and Django but as far as your issue description goes you need to write a verification script that will check whether the user trying to login is already in your users databse or not.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 29, 2019, 9:12am UTC](https://community.auth0.com/t/django-map-auth0-user-onto-existing-users-in-sqlite-database/20335/3 "2019-08-29T09:12:11Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
