0

I am using Django LDAP authentication . By default we would give the LDAP settings in settings.py so that the LdapBackend file would access the settings.py file for the LDAP credentials . But in my case , i need the LdapBackend.py file to look into a separate json file for the LDAP settings . How can I do it?

Thanks

pollirrata
  • 5,188
  • 2
  • 32
  • 50
Pravin Bhasker
  • 95
  • 3
  • 13

2 Answers2

0

You could import json in your settings.py and read the credentials from a JSON file.

Community
  • 1
  • 1
marabu
  • 1,166
  • 7
  • 9
0

You need to load the json file and then read it in using the json module. json.load() will load the whole file at once and convert it to a python object.

import json
with open("filename.json") as json_file:
    ldap_stuff = json.load(json_file)