#How do I initialize an SDK globally in Django?
10 messages · Page 1 of 1 (latest)
Potentially in the wsgi file?
Hmm into this archive wsgi I inicializa the SDK and after how i can use in view?
Is there a reason you can't write a function that initialises the client object and returns it, and just call that from each view you need it?
You can show me one example?
def get_payment_client():
client = Client()
client.do_whatever_you_need_to_initialize()
return client
def my_view(request):
client = get_payment_client()
…
Depending on the implementation and use case, I may put it in the settings or its own module
Importing the initialized version of the client should be enough, it doesn't matter much where you put it; but I'd prefer a place that is imported and executed during Django's initialalization
The sdk is for connect with Payment Gateway, i think i can set The inicial configuration in my settings and call in my view the class
context processors?