从sqlite切换到MongoDB,我遵循了Django MongoDB引擎的所有设置/配置设置。现在,当我通过返回一个HTTP响应到views。py:
中的adduser方法来添加用户时 def adduser(request):
username = request.POST['username']
password = request.POST['password']
u = User.objects.create_user(username, request.POST['email'], password)
u.save()
a = Accounts(user=u)
p = Passwords(user=u)
a.save()
p.save()
user = authenticate(username=username, password=password)
if user is not None and user.is_active:
auth.login(request, user)
return HttpResponseRedirect("/%s/" %u.id)
else:
return HttpResponseRedirect("/account/invalid/")
我得到的错误是:DatabaseError at /adduser
relation "auth_user" does not exist
自MongoDB NoSQL以来,自然不存在这种关系。验证系统不支持还是Mongo-engine有更好的解决方案?也许我应该搬到Postgre去?(sqlite不能同时处理用户,所以不是一个可行的选择)
我看到了这个问题,但那是一年前的事了,所以希望事情已经改变了,因为MongoDB今年已经获得了很多人气。
MongoEngine为使用MongoDB的Django应用程序提供身份验证。