1π
I donβt think it is possible in django ways if you are using multi-tenant package as it is just one app with different schemas, because django loads settings first and then other models follow. but just a gist of idea to work around this is to use environment variables like;
import os
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'dynamic@gmail.com')
this change still takes place once django reloaded.
dirty force reload settings like;
import django
import importlib
django.setup()
importlib.reload(importlib.import_module('yourappname.settings'))
however it will be global changes applied
Yet another advice, is to override the settings before your action inside your code. get the current tenant off the request and override settings manually for this action. check how to patch settings here
How to Unit test with different settings in Django?
Keep trying it is not impossible but just not djangoish clean style.
more resources
https://github.com/edavis/django-override-settings
https://www.djangosnippets.org/snippets/2437/
β UPDATE
you can handle it softly in a middleware and keep your code clean, check this answer
Django multitenant: how to customize django setting "ACCOUNT_EMAIL_VERIFICATION" per tenant?
Hope it helps π
0π
You can change environment settings dynamically:
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"
And another way is to create a function (for example in a class) that gets the parameter like tenant id; and sets or returns the email setting you need.
- [Answered ]-Using double underscore to directly update foreign key's field in Django?
- [Answered ]-Django serve multiple domains with a single instance
- [Answered ]-Why does Django ExtractWeekDay assign the same day to consecutive dates?