mirror of
https://github.com/django/django.git
synced 2024-12-23 17:46:27 +00:00
24 lines
681 B
Python
24 lines
681 B
Python
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
|
|
from django.db import models
|
|
|
|
|
|
class IntegerUsernameUserManager(BaseUserManager):
|
|
def create_user(self, username, password):
|
|
user = self.model(username=username)
|
|
user.set_password(password)
|
|
user.save(using=self._db)
|
|
return user
|
|
|
|
def get_by_natural_key(self, username):
|
|
return self.get(username=username)
|
|
|
|
|
|
class IntegerUsernameUser(AbstractBaseUser):
|
|
username = models.IntegerField()
|
|
password = models.CharField(max_length=255)
|
|
|
|
USERNAME_FIELD = 'username'
|
|
REQUIRED_FIELDS = ['username', 'password']
|
|
|
|
objects = IntegerUsernameUserManager()
|