我有这个类,我尝试使用shell创建对象:
class Task(models.Model):
person = models.OneToOneField(Person)
start_date = models.DateField(null=True)
end_date = models.DateField(null=True)
free_day = models.DateField(null=True)
text = models.CharField(max_length=100)
def __str__(self):
return '%s' % self.person
p = Person.objects.get(username='Herehere')
t = Task(person=p,text='blabla')
t.save()
但我收到了这个错误:
AttributeError: 'DatabaseWrapper' object has no attribute 'Database'
如果我改变
person = models.OneToOneField(Person)
到
person = models.OneToOneField(Person, primary_key)
我得到了
'DatabaseWrapper' object has no attribute 'operators'
我的settings.py数据库配置:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
'ldap': {
'ENGINE': 'ldapdb.backends.ldap',
'NAME': AUTH_LDAP_SERVER_URI,
'USER': AUTH_LDAP_BIND_DN,
'PASSWORD': AUTH_LDAP_BIND_PASSWORD,
},
}