为什么当我尝试登录时django没有识别我的管理员用户/密码?

时间:2012-05-01 00:36:21

标签: django google-app-engine django-admin

这就是我所做的:

> python manage.py createsuperuser
Username (Leave blank to use 'joe'): admin
E-mail address: random_email@yahoo.com
Password:
Password (again):
Superuser created successfully.
Exception AttributeError: "'NoneType' object has no attribute 'mkstemp'" in <bound method DatastoreFileStub.__del__ of <google.appengine.api.datastore_file_stub
.DatastoreFileStub object at 0x02928470>> ignored

> python manage.py shell
[1]: from django.contrib.auth.models import User
[2]: users = User.objects.all()
[3]: users
[3]: [<User: admin>]
[4]: users[0].set_password('password')
[5]: users[0].save()
[6]: exit()
Exeption AttributeError: "'NoneType' object has no attribute 'mkstemp'" in <bound method DatastoreFileStub.__del__ of <google.appengine.api.datastore_file_stub
tastoreFileStub object at 0x028D9490>> ignored

> python manage.py syncbd
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.
Exception AttributeError: "'NoneType' object has no attribute 'mkstemp'" in <bound method DatastoreFileStub.__del__ of <google.appengine.api.datastore_file_stub
.DatastoreFileStub object at 0x02A83310>> ignored

> python manage.py validate
0 errors found
Exception AttributeError: "'NoneType' object has no attribute 'mkstemp'" in <bound method DatastoreFileStub.__del__ of <google.appengine.api.datastore_file_stub
.DatastoreFileStub object at 0x028A3310>> ignored

当我尝试登录时:http://127.0.0.1:8000/admin/,它一直说用户/通过组合是错误的。我需要启用管理页面的任何特定文件吗?

3 个答案:

答案 0 :(得分:1)

就像agf在评论中所说的那样,它看起来像是一个数据库设置问题。模型中定义的内容与数据库中定义的内容之间存在差异。

检查您是否已运行./manage.py syncdb或运行./manage.py validate时会发生什么?

根据评论进行更新

  

App Engine不支持Django模型。你必须写你的   使用App Engine的db.models或ndb.models API的模型。

请参阅此链接:data is stored on localhost but not on gae datastore?

答案 1 :(得分:0)

如果您使用的是1.6.4 SDK,则会出现数据库无法在exit()上保存的错误。

我相信这是在1.6.5上修复的。

答案 2 :(得分:0)

此外,users[0]不会对整个QuerySet进行评估和缓存。您需要评估整个QuerySet或将users[0]分配给某个变量并使用变量:

>>> users[0] is users[0]
False
>>> user = users[0]
>>> user is user
True
>>> len(users); users[0] is users[0]
True

前导难当啊〜