Django error creating admin user django.core.exceptions.ValidationError?

Django error creating admin user django.core.exceptions.ValidationError?

the following error occurs after executing python manage.py createsuperuser and entering the corresponding user name and password, etc.
django.core.exceptions.ValidationError: ["must be a valid date and time format, please use the YYYY-MM-DD HH:MM [: ss [.uuuuuuu]] [TZ] format.]

before creating a superuser, a models module is written, and many time-related fields are involved. I wonder if there will be any contact
Please advise

models.py
from datetime import datetime

from django.db import models
from django.contrib.auth.models import AbstractUser

Create your models here.
class UserProfile(AbstractUser):-sharp

nick_name = models.CharField(max_length=30, verbose_name=u"", default=u"")
birthday = models.DateTimeField(verbose_name=u"",null=True,blank=True,default=u"")
gender = models.CharField(choices=(("male",u""),("femal",u"")),default=u"",max_length=5)
address = models.CharField(max_length=100,default=u"")
mobile = models.CharField(max_length=11,blank=True,null=True)
image = models.ImageField(upload_to="image/%Y/%m",default=u"image/default.img",max_length=100)-sharp

class Meta:
    verbose_name = u""
    verbose_name_plural = verbose_name

def __str__(self):-sharpadmin 
    return self.username
Mar.20,2021

The reason for the

error should be:
DateTimeField corresponds to the format datetime (), you wrote into time.

solution:

  1. either use the datetime () method
  2. use time.strftime ("b d Y H:%M:%S (similar format)", datetime.now)

checked the document, and if you want to update the time from time to time, it seems that you can try: DateTimeField.auto_now


When

extends User , the field birthday has an incorrect default value. The empty string should be changed to None , as follows

class UserProfile(AbstractUser):
    ...
    -sharp birthday = models.DateTimeField(verbose_name=u"",null=True,blank=True,default=u"")
    birthday = models.DateTimeField(verbose_name=u"",null=True,blank=True,default=None)

for expansion steps, please refer to "django 2.0 extended user Field example", https://codeshelper.com/a/11.

"
Menu