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
  • 462,703
  • 120
  • 1,088
  • 1,195
Chandler.Huang
  • 873
  • 3
  • 12
  • 24
  • Here's a pretty good explanation: http://stackoverflow.com/questions/2680902/python-django-global-variables – alecxe Apr 19 '13 at 06:24

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
  • 48,760
  • 8
  • 117
  • 177