【问题标题】:Using built in Django authentication/User model with Mongodb在 Mongodb 中使用内置的 Django 身份验证/用户模型
【发布时间】:2011-11-03 17:10:07
【问题描述】:

从 sqlite 切换到 MongoDB,我遵循了 Django MongoDB Engine 的所有设置/配置设置。现在,当我通过从 view.py 中的 adduser 方法返回 HTTP 响应来添加用户时:

 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 不能同时处理用户,所以不是一个可行的选择)

我看到this 的问题,但那是一年前的事了,所以希望到那时事情已经发生了变化,因为 MongoDB 在今年获得了很大的普及。

【问题讨论】:

    标签: python django authentication mongodb mongoengine


    【解决方案1】:

    MongoEngine 使用 MongoDB 为 Django 应用程序提供身份验证。

    【讨论】:

    • 它只是 django.contrib.auth 的一个分支,我可以说它已经过时了,因为使用了不推荐使用的哈希密码等等......
    猜你喜欢
    • 2011-12-23
    • 1970-01-01
    • 1970-01-01
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 2012-10-06
    • 2013-12-23
    相关资源
    最近更新 更多