django_auth_ldap 对比使用 Django 模型的 postgres 数据库
django_auth_ldap vs postgres db using django models
我正在创建一个应用程序,在标准用户模型的帮助下,我将用户存储在 Postgres 数据库中,在我的 Django 应用程序中,我使用 Django 查询来获取所有需要的信息,例如 "first_name","username" .. 等等
我实现了 Django_auth_ldap 以开始在 Openldap 服务器中存储用户身份数据(如果需要)。但是现在,我对如何获取过去使用 Django 查询获取的数据感到困惑。
我不想改变我认为的行为,我想继续使用 Django 查询
这似乎描述了您想要的一些内容:https://django-auth-ldap.readthedocs.io/en/latest/users.html
You can perform arbitrary population of your user models by adding listeners to the Django signal: django_auth_ldap.backend.populate_user
. This signal is sent after the user object has been constructed (but not necessarily saved) and any configured attribute mapping has been applied (see below). You can use this to propagate information from the LDAP directory to the user object any way you like. If you need the user object to exist in the database at this point, you can save it in your signal handler or override get_or_build_user()
. In either case, the user instance will be saved automatically after the signal handlers are run.
我正在创建一个应用程序,在标准用户模型的帮助下,我将用户存储在 Postgres 数据库中,在我的 Django 应用程序中,我使用 Django 查询来获取所有需要的信息,例如 "first_name","username" .. 等等
我实现了 Django_auth_ldap 以开始在 Openldap 服务器中存储用户身份数据(如果需要)。但是现在,我对如何获取过去使用 Django 查询获取的数据感到困惑。
我不想改变我认为的行为,我想继续使用 Django 查询
这似乎描述了您想要的一些内容:https://django-auth-ldap.readthedocs.io/en/latest/users.html
You can perform arbitrary population of your user models by adding listeners to the
Django signal: django_auth_ldap.backend.populate_user
. This signal is sent after the user object has been constructed (but not necessarily saved) and any configured attribute mapping has been applied (see below). You can use this to propagate information from the LDAP directory to the user object any way you like. If you need the user object to exist in the database at this point, you can save it in your signal handler or overrideget_or_build_user()
. In either case, the user instance will be saved automatically after the signal handlers are run.