Open olmari opened 10 months ago
In my testing I don't see any difference on where the settings_local is loaded.
1) uncomment "ACCOUNT_IBAN": (ACCOUNT_IBAN, "IBAN of the association's bank account"),
in CONSTANCE_CONFIG
in settings.py
2) add ACCOUNT_IBAN = "ABC123"
in settings_local.py
(the default value in settings.py is "FI12 3456 789"
3) run ./manage.py shell_plus
4) in the shell run
from constance import config
print(config.ACCOUNT_IBAN)
and it prints out ABC123
But what I do see is that Constance has added an object for the setting even if I have never saved anything into it...
Constance.objects.get(key='ACCOUNT_IBAN').value
Looks like constance initializes its objects when the key is queried for the first time. It will take the default value configured at that point in time and then keeps it in the db.
That would conceptually match why local settings loading as last thing would make it also go...
Does generally things know local settings has priority? Or how else they know other than loading local settings in settings.py as last thing "overriding" anything set prior? Tho goes too deep into code for my knowledge anyways, kinda, sorta.
Just to clarify: Here is the sequence of operations we need:
Local settings should always override, therefore we need to override the constance config in the end, if applicable
In drxf/settings.py move importing of local settings last thing that is done, this way any/all custom settings gets priority as they're loaded last.
Fixes: https://github.com/TampereHacklab/mulysa/issues/460
Signed-off-by: Sami Olmari sami@olmari.fi