I want to execute some code at startup of Django server but I want it to run only once. Currently when I start the server it\'s executed twice. Documentation says that this
if you don't want to use --noreload
you can:
replace the line in your app's __init__.py
that you use to specify the config:
default_app_config = 'mydjangoapp.apps.MydjangoappConfig'
by this:
import os
if os.environ.get('RUN_MAIN', None) != 'true':
default_app_config = 'mydjangoapp.apps.MydjangoappConfig'