0

I am creating an app where I store the USERS in a Postgres database with the help of the standard User Model, in my Django app i use Django queries to get all needed information, like "first_name", "username" .. etc

I implemented Django_auth_ldap to start storing user identification data in an Openldap server if i want. But now, i'm confused to how to get the data i used to get using django queries.
i don't want to change the behavior in my views, i want to continue using Django queries

Mohamed Benkedadra
  • 1,964
  • 3
  • 21
  • 48

1 Answers1

1

This looks like it describes some of what you want: 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.

Thymine
  • 8,775
  • 2
  • 35
  • 47