小编Cp *_*rma的帖子

预期的字符串或缓冲区,date_re.match(value)django错误

我想扩展django中的自定义用户模型。我从django官方网站复制粘贴代码。当我想迁移它时会抛出错误

TypeError: expected string or buffer
Run Code Online (Sandbox Code Playgroud)

models.py

education=models.CharField(max_length=13)

from django.db import models
from django.contrib.auth.models import (
    BaseUserManager, AbstractBaseUser
)


class MyUserManager(BaseUserManager):
    def create_user(self, email, date_of_birth, password=None):
        if not email:
            raise ValueError('Users must have an email address')

        user = self.model(
            email=self.normalize_email(email),
            date_of_birth=date_of_birth,
        )

        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_superuser(self, email, date_of_birth, password):
        user = self.create_user(email,
            password=password,
            date_of_birth=date_of_birth
        )
        user.is_admin = True
        user.save(using=self._db)
        return user


class MyUser(AbstractBaseUser):
    email = models.EmailField(
        verbose_name='email address',
        max_length=255,
        unique=True,
    )
    date_of_birth = models.CharField(max_length=20)
    is_active = models.BooleanField(default=True)
    is_admin …
Run Code Online (Sandbox Code Playgroud)

python django django-migrations

5
推荐指数
1
解决办法
2929
查看次数

标签 统计

django ×1

django-migrations ×1

python ×1