Reputation: 3262
how to get User id from auth_user
table in django. Suppose username is availlable to me.
Upvotes: 6
Views: 16182
Reputation: 545
User doesn't have backend so you have to use a UserManager (or BaseUserManager if you have custom User class)
BaseUserManager.get_by_natural_key(username)
Upvotes: 1
Reputation: 62908
Assuming the user exists:
from django.contrib.auth.models import User
User.objects.get(username=the_username).pk
Upvotes: 19