Django models 如何使用自己的模型手动登录?德扬戈

Django models 如何使用自己的模型手动登录?德扬戈,django-models,django-forms,django-templates,django-views,Django Models,Django Forms,Django Templates,Django Views,我想用我自己的模型做一个手动登录方法。我读了文档,但不知道如何使用 这: 这是我的Usuario模型: class Usuario(models.Model): id_usuario = models.AutoField(primary_key=True) nombre = models.CharField(max_length=255) correo_electronico = models.EmailField() direccion = models.CharField(max_leng

我想用我自己的模型做一个手动登录方法。我读了文档,但不知道如何使用 这:

这是我的Usuario模型:

class Usuario(models.Model):

id_usuario = models.AutoField(primary_key=True)
nombre = models.CharField(max_length=255)
correo_electronico = models.EmailField()
direccion = models.CharField(max_length=255)
telefono = models.CharField(max_length=50)
usuario = models.CharField(max_length=255)
contrasenia = models.CharField(max_length=255, null=True ,blank=True)
id_perfil = models.ForeignKey(Perfil, on_delete=models.CASCADE)
fecha_creacion =  models.DateTimeField(auto_now_add=True)
fecha_modificacion = models.DateTimeField(null=True)
fecha_cancelacion = models.DateTimeField(null=True)
status = models.CharField(max_length=50)

def __str__(self):
    return '{}'.format(self.nombre)

您的视图将用于默认身份验证系统。但是,考虑到您的用户模型,我认为您正在寻找自定义身份验证系统。最好看一看。简而言之,您需要一个自定义模型、表单和后端。您还应该确保settings.py指定应该查找哪个后端Django

class Usuario(models.Model):

id_usuario = models.AutoField(primary_key=True)
nombre = models.CharField(max_length=255)
correo_electronico = models.EmailField()
direccion = models.CharField(max_length=255)
telefono = models.CharField(max_length=50)
usuario = models.CharField(max_length=255)
contrasenia = models.CharField(max_length=255, null=True ,blank=True)
id_perfil = models.ForeignKey(Perfil, on_delete=models.CASCADE)
fecha_creacion =  models.DateTimeField(auto_now_add=True)
fecha_modificacion = models.DateTimeField(null=True)
fecha_cancelacion = models.DateTimeField(null=True)
status = models.CharField(max_length=50)

def __str__(self):
    return '{}'.format(self.nombre)