【发布时间】:2016-08-08 14:40:16
【问题描述】:
我正在使用 django 1.7.11。我有一个预先存在的项目,我决定尝试使用内置的管理面板(我还没有创建超级用户)。当我打开身份验证页面时,我看到了:
考虑到表可能有问题我决定删除sqlite数据库并重新运行所有内容:
$ python manage.py makemigrations app1
Migrations for 'app1':
0001_initial.py:
- Create model Seller
$ python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: crispy_forms
Apply all migrations: admin, contenttypes, auth, app1, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying app1.0001_initial... FAKED
$ python manage.py syncdb
Operations to perform:
Synchronize unmigrated apps: crispy_forms
Apply all migrations: admin, contenttypes, auth, app1, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
You have installed Django's auth system, and don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Created:
Error: '' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.
Created:
我该如何解决这个问题?
编辑:
app1/models.py:
from django.db import models
# from django.contrib.auth.models import AbstractUser
class Seller(models.Model):
# Address
contact_name = models.CharField(max_length=50)
contact_address = models.CharField(max_length=50)
contact_email = models.CharField(max_length=50)
contact_phone = models.CharField(max_length=50)
............
created = models.DateTimeField(auto_now_add=True,unique=True)
REQUIRED_FIELDS = ('contact_name','contact_email','contact_address','contact_phone')
USERNAME_FIELD = 'created'
【问题讨论】:
-
你能在 app1 中发布你的 models.py 吗? AUTH_USER_MODEL 未指向您发布的屏幕截图中的实际模型。您是否打算使用自定义用户模型?