1

I wrote some global variable which takes some time to initial in views.py. Instead of responding after requesting, I would like to make those variable initialed while the server starting. Is there any way to do it? I have try google about it but in vain. I think I couldn't be the first one have this kinda of needs. Thanks.

alecxe
  • 441,113
  • 110
  • 1,021
  • 1,148
Chandler.Huang
  • 853
  • 2
  • 10
  • 23

1 Answers1

1

It seems you are talking about settigs, that means, variables that are fixed at start time.

You can set this kind of vars in settigs.py and access them importing settings:

settings.py

MYSETTING = some expression

views.py

from django.conf import settings
...
mycalc = ... MYSETTINGS ...
dani herrera
  • 44,444
  • 7
  • 103
  • 165